解决 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

[root@localhost ansible-pandora]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@localhost ansible-pandora]# find / -name *.sock
/run/rpcbind.sock
/mysql_data/3306/mysql.sock
[root@localhost ansible-pandora]# ln /mysql_data/3306/mysql.sock /tmp/mysql.sock
[root@localhost ansible-pandora]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.39-log MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

posted @ 2022-11-08 14:01  梧桐潇雨  阅读(491)  评论(0)    收藏  举报