Error when starting mysql

When connecting to the Mysql database through the command mysql -u username -p password

报错 "can't connect to local mysql serverthrough  socket'/var/run/mysqld/mysqld.sock'

 mysql -u root -p
Enter password:

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

Workaround :

In the case of not reinstalling mysql, it can be solved by the following commands. Specifically, stop the mysql service first, and then restart the mysql service

cd /etc/init.d

sudo service mysql stop

sudo service mysql start

After execution, the mysql database can be enabled

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326504996&siteId=291194637