Database connection problem on modsecparse.pl Imprimer

  • 1

How to fix Database connection problem on modsecparse.pl file?

Are you receiving the Modsec Database Failure cron error continuously ?  Mostly these mod security error caused due to mysql connection problem. You should check your mysql connectivity on modsecparse.pl file.

mod security DB error

root@gopal [~]#/etc/cron.hourly/modsecparse.pl:
DBI connect('modsec:localhost','modsec',...) failed: Access denied for user 'modsec'@'localhost' (using password: YES) at /etc/cron.hourly/modsecparse.pl line 19
Unable to connect to mysql database at /etc/cron.hourly/modsecparse.pl line 19.
Also check with your apache webserver whether the mod_security installed properly. Use the following commands to verify the installation status and confirm if they are loading.

# find /usr/local/apache -regex ".*modsec.*\|.*mod_security.*" | sort
# /usr/local/apache/bin/httpd -l | grep "unique_id"
# /usr/local/apache/bin/httpd -M | egrep "sec|unique_id"
Please make sure the password used on the “my $dbpassword” line in /etc/cron.hourly/modsecparse.pl matches the “modsec” password in MySQL.

 

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

If you still received the database connection problem on modsecparse.pl then the modsecparse.pl script is trying to connect to the socket at /tmp/mysql.sock, but the location of the socket is /var/lib/mysql/mysql.sock. The mod security script use a localhost connection to determine the actual location of the socket file. Anyway set the value mysql_socket location instead of localhost to fix it.

# my $dbhost = 'localhost';
my $dbhost = 'mysql_socket=/var/lib/mysql/mysql.sock';

After that changes you manually check the mod sec perl file.

root@gopal [/]# /etc/cron.hourly/modsecparse.pl
root@gopal [/]#

Cette réponse était-elle pertinente?

« Retour