7

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?

  • Did the MySQL service successfully start? Check its log. – Shane Madden May 16 '12 at 16:53
  • It starts, but no process shows up. – Markum May 16 '12 at 21:07
  • I had this error just now, and it turned out to be an error in the configuration file which I had just modified. – linitbuff Jan 5 '13 at 7:39
  • Hi is a simple approach that got this fixed for me: k2013joseph.wordpress.com/2015/02/08/… – Kaweesi Joseph Feb 8 '15 at 6:44
2

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.

1

Try the following

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

Then start mysql...

  • Done, but nothing happens when I do service mysql start, or stop. But when I do stop it and use the client it still gives me the error, as if it was still on. I think I may have two MySQL servers conflicting. – Markum May 16 '12 at 21:09
0

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 /var/log/mysql/error.log

  • Nope, no process. And there is no error lo file. – Markum May 16 '12 at 21:07
0

First start the mysql server

then run this command

ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.