mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111
时间: 2023-12-19 18:32:27 浏览: 97
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
以下是两种解决MySQL连接问题的方法:
1. 检查MySQL服务是否正在运行,如果没有运行,请启动MySQL服务:
```shell
sudo service mysql start
```
2. 如果MySQL服务已经在运行,但是仍然无法连接,可以尝试通过指定socket文件的方式连接MySQL:
```shell
mysql -uroot -p --socket=/var/run/mysqld/mysqld.sock
```
阅读全文