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 this error message while trying to connect to a local MySQL Server. Mostly It means either the MySQL server is not installed/running.

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

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

$ sudo service mysqld restart
sudo service mysqld restart
  • Save
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
  • Save
sudo systemctl daemon-reload

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

About the author

Rohan Kamble

I am a Web Developer by profession, who loves the web to the core with over 8 Years of Experience on working a wide range of domains like websites on e-commerce, matrimonial, company’s professional sites, Finance, company internal communications and many more…

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.