解决Mysql不能连接问题: Can't connect to local MySQL server through socket '/var/lib/mysql/

1.首先检查mysql 服务是否打开 

service mysql status 

如果显示active则略过,inactive则 service mysql start

2.检查 my.cnf文件是否被正确配置 (在/etc/mysql/路径下)

[mysqld]

datadir =/var/lib/mysql/

socket =/var/lib/mysql/mysql.sock

3.需要给路径相应的访问权利

chown mysql:mysql -R /var/lib/mysql/*

chmod 755 -R /var/lib/mysql/*

4.重启mysql服务

service mysql restart

你可能感兴趣的:(解决Mysql不能连接问题: Can't connect to local MySQL server through socket '/var/lib/mysql/)