Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)解决方法

登陆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' (111)解决方法

解决办法:

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' (111)解决方法

报了: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' (111)解决方法

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)解决方法

很明显,不是权限问题。

4、启动

/etc/init.d/mysqld start

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' (111)解决方法

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

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 '(2) ;


下一篇:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)