MySQL version: 5.5.28-0ubuntu0.12.04.2-log
I just upgraded my 64-bit server from Ubuntu 10.04 to 12.04.1 not quite a month ago. Since then, this issue has come up a few times in the Apache error log and no other logs seem to have any entries pointing to a cause:
PHP Warning: mysql_connect(): Lost connection to MySQL server at ‘waiting for initial communication packet’, system error: 95
And, naturally, this error follows:
PHP Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
A mysql restart solves it or it resolves itself after a few minutes, but I’d rather not have it happen at all.
I have a second server configured the exact same and it doesn’t have the issues, but it was upgraded over two months ago and doesn’t have the same user or data volume.
Some sites suggest changing the mysql wait_timeout value to a lower number than the default of 28800.
After this happened today, I ran mysqlcheck to check and auto-repair the tables, but it happened again about 8 hours later. During the last incident, I tried to connect to mysql from the command line (#mysql -u root -p), but couldn’t:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)
/var/run/mysqld/mysqld.sock was there, though. I checked before restarting.
Since I was there, I restarted Apache first to see if it was the culprit (unclosed handles), but it didn’t help. Could be a restart doesn’t pause long enough to close the handles.
This is getting serious. Does anyone have any suggestions?