Solve ERROR: 2002 (HY000): Can’t connect to local MySQL server through socket

  • Post last modified:December 21, 2020
  • Reading time:1 mins read

It is very frustrating when you see this ERROR 2002 (HY000): Can’t connect to local MySQL server through socket on your terminal when you try to open MySQL.

Actually we will share you the process through which you can resolve the issue

I hope so you forgot the password or have not set up the MySQL properly

No issue this article we will resolve this issue

In this article we will reset the password

Method

Step By Step You need to follow my guidelines

  1. Stop mysql
$ sudo /etc/init.d/mysql stop

2.Start mysql in safe mode

$ sudo mysql_safe --skip-grant-tables &

3.Log into MySQL using root

$ mysql -uroot

4.Select the MySQL database to use

use mysql;

5.Reset the password

update user set password=PASSWORD("mynewpassword") where User='root';

6.Flush the privileges

flush privileges;

7.Restart the server

quit

8.Stop and start server again

$ sudo /etc/init.d/mysql stop

9.Login with a new password

$ mysql -u root -p

10.Now you can set the set new password.

Conclusion

This was the few steps you can solve this issue ERROR 2002 (HY000) Can’t connect to local MySQL server through socket.

Read this: How to find saved Wi-Fi password in Ubuntu-based or any other?

Like what you read? Please share it with others.
guest
0 Comments
Inline Feedbacks
View all comments