Tuesday, May 31, 2011

How to solve intermittent ';Can't connect to MySQL server';?

Hi there,



Recently, I started getting small periods of intermittent connection errors (Error number 2002) about once every hour, lasting for about 1 to 5 minutes each time:

Can't connect to local MySQL server through socket

'/var/lib/mysql/mysql.sock'



- Not using persistent connections

- All PHP scripts close their connection to mysql

- maximum connection limit is about twice that of the peak amount of users online at once.



Also

- server doesn't crash/restart, it keeps running

- errors don't match the number of users online on the website



Made 5 changes thusfar

- changed the directory containing the mysql.sock to protect it

- I changed the default socket file setting in both my.cnf and php.ini

- disabled SELinux completely, rebooted the server and double-checked that it is indeed disabled.

- Changed the maximum amount of open files allowed by the operating system from 1024 to 30000.

- tried using tcp/ip



still getting the errorsHow to solve intermittent ';Can't connect to MySQL server';?
What version of MySQL are you running? You could try to check at the mysql web site if there is any patch available to correct this problem because it seems to be a problem of MySQL itself.

No comments:

Post a Comment