MySQL:Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock

在/etc/my.cnf文件中添加如下内容,并重启mysqls服务,即可解决mysql,mysqldump,mysqladmin的“Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'”问题

[mysqld]
datadir=/opt/mysql/
socket=/opt/mysql/mysql.sock
 
[mysql]
socket=/opt/mysql/mysql.sock
 
[mysqldump]
socket=/opt/mysql/mysql.sock
 
[mysqladmin]
socket=/opt/mysql/mysql.sock

 重启

service mysqld restart

你可能感兴趣的:(运维,mysql,adb,数据库)