Single Blog

Database Connection Problems – User modsec /etc/cron.hourly/ on cPanel

January 11, 2017, Written by 0 comment

Database connection problems with are usually caused by an issue with mod_security. You will receive an email an hour such as the below, informing you that there is a problem with the service.

/etc/cron.hourly/  DBI connect('modsec:','modsec',...) failed: Access denied for user 'modsec'@'localhost' (using password: YES) at /etc/cron.hourly/ line 20 Unable to connect to mysql database at /etc/cron.hourly/ line 20.

The resolution to enable connectivity is straight forward. To double check there is an issue with connectivity, in SSH type –


If it is working, it won’t throw out any error….. If not, you will see a DBI connect failure message. What we need to do this, grab the password for the service from /etc/cron.hourly/

nano /etc/cron.hourly/

You will see the dbpassword line with the password, copy this into a local text document –

my $dbpassword = 'r7asda2YPnPJ1';

Now you will need to load up mysql, in SSH type

mysql mysql

We then update the password for user modsec with the password we collected from the file

mysql > update user set Password=password('r7asda2YPnPJ1') where User='modsec';

Flush the privileges

mysql > flush privileges;

And all done!

mysql > quit; To check modsecparse is now running, type the below into the command line

/etc/cron.hourly/ If no errors show, modsecparse is back up and running again!

James Ensor