mysql数据库提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
①无提示无法通过/var/lib/mysql/mysql.sock连接数据库;
[root@proeim 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:
[root@proeim 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>