连接数据报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql

Posted aibudongshiting

tags:

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

1、lamp环境使用数据库报错:

技术分享图片

2、编辑/etc/php.ini/文件中"mysql 下找到"mysql.default_socket",并设置其值指向正确的mysql服务socket文件即可,  在配置文件中添加“[client]”选项和“[mysql]”选项,并使用这两个选项下的“socket”参数值,与“[mysqld]”选项下的“socket”参数值,指向的socket文件路径完全一致。如下: 

技术分享图片

3、重启服务器就得以解决

 

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

解决MySQL报错ERROR 2002 (HY000)

连接数据报错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/mys

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

TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory

mysql客户连接时报ERROR 2002 (HY000)