Blog

Modsecparse.pl cron job: connection to mysql database fails

Tags: mod_secMySQLpassword reset

Published on: September 26, 2014 by Felix

Modsecparse.pl cron job:  connection to mysql database fails

Scenario:

The modsecparse.pl cronjob producing the following modsecparse.pl database connection error

/etc/cron.hourly/modsecparse.pl:

DBI connect('modsec:localhost','modsec',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /etc/cron.hourly/modsecparse.pl line 19

Unable to connect to mysql database at /etc/cron.hourly/modsecparse.pl line 19.

Solution

Try reproducing the error by running the cron job manually:

#/etc/cron.hourly/modsecparse.pl

If it shows the same error, make sure the password used on the “my $dbpassword” 19th line in /etc/cron.hourly/modsecparse.pl matches the “modsec” password in MySQL.

my $dbpassword = ‘sample’;

You can reset the “modsec” MySQL password by following these steps:

    mysql > use modsec;
    mysql> update user set Password=password('sample') where User='modsec';
    mysql > flush privileges;
    mysql> quit;

 

Also in WHM Click Service Manager -> Check enable mysql and mysql monitor boxes -> Save changes. It should solve problem.

mod_sec_cron

Get 24/7 expert server management

Category : Howtos, MySQL, Troubleshooting

Felix

Felix

Firaz has been in the Web Hosting industry since 2012. He is always fascinated in resolving complicated DNS, cPanel and other Web hosting issues. He loves to help newbies to climb the hill from a fresher to an experienced System admin. Movies and songs are his favourite passtime.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Categories

Your Cart

Cart is empty.

Subtotal
₹0.00
APPLY
0
Send this to a friend