Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

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

David Carr

Development

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
Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.