首页 > 代码库 > ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

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

原因:找不到mysql.sock文件

解决方法:

1 找到mysql.sock文件位置

echo "show variables" | mysql | grep "socket"或者echo "status" | mysql | grep "socket"

2 ln -s /var/lib/mysql /mysql .sock /tmp/mysql .sock

将两个文件做一个软连接

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