Development

David Carr

Fixing ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I had a crash after a reboot, then MySQL would not run, the error I was getting was:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I tried to kill the PID which is what most posts recommend, but the error remained 

This command did the trick for me, my installed MySQL version is just mysql if you're is like mysql@5.7 then adjust the name on the end of the command.

sudo chown -R _mysql:mysql /usr/local/var/mysql && sudo brew services restart mysql

Thank you to the StackOverflow user FooBar

 

Another approach is to change MySQL Permissions:

sudo chown -R _mysql:mysql /usr/local/var/mysql

Then start MySQL

sudo mysql.server start

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2020 DC Blog. All code MIT license. All rights reserved.