mysql数据库提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/m

Posted 蜗牛前进的方向

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql数据库提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/m相关的知识,希望对你有一定的参考价值。

①无提示无法通过/var/lib/mysql/mysql.sock连接数据库;
[[email protected] mysql]# mysql -uxxx -pxxx -Dxxx -A
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2
②排查发现是因为该目录下缺少mysql.sock文件;
③通过软连接的形式来复制得到相关文件:
cd /var/lib/mysql/
ln -s /tmp/mysql.sock  mysql.sock
④查看mysql的状态:
service mysqld-ib status
MySQL is not running, but lock exists [FAILED]
⑤然后启动mysql:
[[email protected] bin]# service mysqld-ib start
Starting MySQL.. [ OK ]
 
⑥然后连接mysql,发现连接成功了:
 
mysql -uxxx -pxxx -Dxxx -A
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 358878
Server version: 5.1.40 build number (revision)=IB_4.0.7_r16961_17249(ice) (static)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.
mysql>
 

以上是关于mysql数据库提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/m的主要内容,如果未能解决你的问题,请参考以下文章

mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock&

centos6 mysql数据库启动问题

mysql报错-ERROR 2002

解决MySQL报错ERROR 2002 (HY000)

解决MySQL报错ERROR 2002 (HY000)

启动mysql 报错: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib