Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘

百里朝
2023-12-01

mysql登陆的时候出现了如下情况

[root@hwzsc-ctc-crm-qtp-0002 ~]# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

在tmp目录上面找不到mysql.sock,通过搜索发现是有的,只要创建一个软链接过去就可以了

[root@hwzsc-ctc-crm-qtp-0002 ~]# find / -name mysql.sock
/var/lib/mysql/mysql.sock
[root@hwzsc-ctc-crm-qtp-0002 ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@hwzsc-ctc-crm-qtp-0002 ~]# mysql -u root-p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1062
Server version: 5.7.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> show databases;
 类似资料: