November 1st, 2013, 12:30 PM
Can't connect to local MySQL server / MySQL error log
My Debian VPS website has been fine for months and then today suddenly gave the error "can't connect to local MySQL server through socket /var/run/mysqld/mysqld.sock". I looked at the resources (RAM, hard disk, CPU, traffic) and there were plenty of resources to spare. It was ok again after I rebooted the VPS.
Any ideas please how this might happen? Should I expect any clues from today's /var/log/mysql/mysql.log ? This is a very big file (110 MB / 650,000 lines) which I think is mostly today's MySQL queries but it does not seem to mention this error. Would MySQL errors usually be in this file or should there be a separate file for errors?
November 3rd, 2013, 01:25 PM
That's the General Query Log which as you noticed contains all queries that has been issued against your server since the last log rotation.
You should look for a file that's usually named something like mysql.err or yourHostName.err.
Read here: http://dev.mysql.com/doc/refman/5.6/en/error-log.html
Did you check if the socket was still at /var/run/mysqld/mysqld.sock _before_ you rebooted the server?
My guess is that either your MySQL server has been restarted and you have conflicting configuration files.
Or that your PHP (I'm guessing that's what you are using since you didn't mention anything about it) might have conflicting configurations or that the user that Apache runs as didn't have access to the socket, etc.
Basically the only thing you can do is to troubleshoot it when the problem exists. The error logs and the syslog etc might tell you a piece of the story so yes go through those first.
November 3rd, 2013, 02:51 PM
@ sr thanks for your reply. It is Debian LAMP. It has run fine for months and I haven't done anything to cause a change. There is a mysql.err in /var/log but it is empty so not much help. Any suggestions please what I should do if it happens again?