I just upgraded my MySQL server on Debian. However now when I start the server and try connect to it I get the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
How can I fix this?
I know this question is five months old, but since I've run into the same problem on three different upgrades, I thought I'd post my solution anyway.
In my case, this seems to be due to a bug in the Debian update scripts (so the problem might crop up in Ubuntu as well). Somehow, some of the binary log files wind up with the wrong ownership after the upgrade process is complete. This prevents the server from gaining write access to its own logs, so it fails to start.
On Debian (at least on our servers) these files all live in
/var/lib/mysql. Everything in there should be owned by user mysql and group mysql. However, some of the files
mysql-bin.* were owned by root after the upgrade. Changing the ownership of the logfiles back to mysql allowed the server to start correctly:
# chown mysql:mysql /var/lib/mysql/mysql-bin.* # /etc/init.d/mysql start
I hope this saves someone some time.
Try the following
mkdir /var/run/mysql chown mysql:mysql /var/run/mysql
Then start mysql...
MySQL most likely failed to start. Try running
ps aux | grep mysqld to see if there's a process ID for the mysql daemon.
To expand on Shane's comment, check the MySQL log for reasons for it failing to start. The default location is
First start the mysql server
then run this command
ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock