解决MySQL不能通过mysql.sock连接的问题

情况如下:

[root@localhost opt]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决办法:
[root@localhost opt]#cat /etc/my.cnf

查看 "socket="后面的字符串。
默认应该是/tmp/mysql/mysql.sock
比如被修改为是 /tmp/mysql.sock
那么这样就可以连接了:

[root@localhost opt]# mysql --socket=/tmp/my.cnf -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4521 to server version: 5.0.18-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>



欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php