can't connect to local mysql server through socket '/tmp/mysql.socket'
时间: 2023-09-09 16:14:03 浏览: 148
This error message usually occurs when the MySQL server is not running or the socket file is missing or inaccessible. Here are some troubleshooting steps you can try:
1. Check if the MySQL server is running by running the following command in your terminal:
```
sudo systemctl status mysql
```
If the server is not running, start it using the following command:
```
sudo systemctl start mysql
```
2. Check if the socket file exists in the correct location by running the following command in your terminal:
```
ls -l /tmp/mysql.sock
```
If the file is missing, you can create a new socket file using the following command:
```
sudo touch /tmp/mysql.sock
sudo chmod 777 /tmp/mysql.sock
```
3. Check if the MySQL configuration file is pointing to the correct socket file. Open the file `/etc/mysql/mysql.conf.d/mysqld.cnf` and look for the following line:
```
socket = /tmp/mysql.sock
```
If the line is commented out or pointing to a different location, change it to the correct location and save the file. Then, restart the MySQL server using the following command:
```
sudo systemctl restart mysql
```
If none of these steps solve the issue, it might be a more complex problem that requires further investigation.
阅读全文
相关推荐


















