ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2) - Photo by Brina Blum on Unsplash

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2)

82 / 100 SEO Score

A complete guide to resolve ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2)

When I tried to log into MySQL server with below command

$ mysql -u root -p

I got below error

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

If you ever bumped into an above error message while trying to connect to a local MySQL Server, mostly It means either the MySQL server is not installed/running and hence the error

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2)

To check  the status of MySQL service
$ service mysqld status
service mysqld status
service mysqld status

If the MySQL service is inactive (dead), restart the service using below command

$ sudo service mysqld restart
sudo service mysqld restart
sudo service mysqld restart

For me, MySQL showed this warning along with the fix command, so I fired the given command which took me next command prompt without any output and when I again checked the status of MySQL service It was running all fine

$ sudo systemctl daemon-reload
sudo systemctl daemon-reload
sudo systemctl daemon-reload

Now that the MySQL server is started, you will be able to login to MySQL server.

Hope, this article helped you fix the issue, if yes, just let me know in the comments so that it will motivate me to post more articles like this.

Other popular readings on the blog

About the author

Rohan Kamble

A Web Developer by profession, who loves the web to the core with over 9 Years of Experience working on a wide range of domains like websites on e-commerce, Travel, Alumni, matrimonial, company's professional sites, Finance, company internal communications and many more. Also WordPress Plugins & Chrome extensions.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.