mysql报错Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)很明显,找不到/var/lib/mysql/mysql.sock,这是因为默认的socket是在/tmp/mysql.sock编辑/etc/my.cnf,修改socket (client和server的都要改)socket ...
·
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
很明显,找不到/var/lib/mysql/mysql.sock
,这是因为默认的socket
是在/tmp/mysql.sock
编辑/etc/my.cnf
,修改socket
(client和server的都要改)
socket = /var/lib/mysql/mysql.sock #默认是/tmp/mysql.sock
然后重启mysql,但是shell输出:
mysqld_safe mysqld from pid file /usr/local/mysql/data/iZm5e0mgr2ayoxe7szl6i2Z.pid ended
查看mysql错误日志:
tail -f /usr/local/mysql/data/iZm5e0mgr2ayoxe7szl6i2Z.pid
报错为:
[ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
2个原因:
/var/lib/mysql 目录不存在
/var/lib/mysql 存在,但是权限不够
创建文件夹并授权:
mkdir -p /var/lib/mysql; # -p表示如果没有parent文件夹,就创建
chmod -R 777 /var/lib/mysql;
重启mysql,成功。
更多推荐
已为社区贡献10条内容
所有评论(0)