A complete guide to resolve ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2)
$ 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
If the MySQL service is inactive (dead), restart the service using below command
$ 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
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