【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

时间:2024-12-15 09:08:15

登陆mysql的时候,出现了这个问题: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

解决办法:

1、先删除mysql.sock

cd /var/lib/mysql
mv  mysql.sock  mysql.sock.bak

2、再次登陆

mysql -uroot -p123456

会出现下面的问题:

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

报了:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)的错。

3、看看mysql的状态,另外看看是不是mysql的权限问题

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

很明显,不是权限问题。

4、启动

/etc/init.d/mysqld start

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

问题解决,在var/lib/mysql下会出现mysql.sock。

【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

转载:https://www.cnblogs.com/invban/p/5824796.html