The Problem: mod_security plugin could not connect to the database
Someone recently came up with the following error when trying to use the Mod Security plugin in cPanel: ‘The mod_security plugin could not connect to the database. Please verify that MySQL is running. Error: Access denied for user ‘modsec’@’localhost’ (using password: YES)’
The problem is that the database can’t be accessed. This is usually due to the database user being unable to access the database. The quick and easy fix is to get the password out of /cron.hourly/modsecparse.pl ad then use it to reset the password using mysql. You can just copy/paste the following command line script to do the job for you. Make sure you scroll to get the whole thing!
The Easy Fix
pass=`grep dbpassword /etc/cron.hourly/modsecparse.pl | sed '/dbuser/d' | cut -d"'" -f2`;\ mysql -qbse "GRANT ALL ON modsec.* to modsec@localhost IDENTIFIED BY '$pass'";
If you run into any snags trying this, let me know in the comments below.