ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Solution 1:

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.

Solution 2:

Try the following

mkdir /var/run/mysql
chown mysql:mysql /var/run/mysql

Then start mysql...