ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql

Posted 大道至简

tags:

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

当使用host参数为“localhost”连接mysql服务时,会优先使用“sock文件”进行连接,而不是使用“IP:端口”进行连接,而Mysql尝试使用“sock文件”进行连接时,却无法获取“sock文件”的位置。


要解决此错误,解决方法:

 

 

将连接参数“host”的值由“localhost”改成“127.0.0.1”;


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

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

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

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock'

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

尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (