Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
时间: 2023-09-29 17:04:49 浏览: 44
This error message usually indicates that the MySQL server is not running or that the socket file is missing or inaccessible. Here are some steps to troubleshoot the issue:
1. Check if MySQL server is running: `sudo service mysql status`
2. If MySQL server is not running, start it: `sudo service mysql start`
3. If MySQL server is running, check if the socket file exists: `ls -l /var/lib/mysql/mysql.sock`
4. If the socket file does not exist, create it: `sudo touch /var/lib/mysql/mysql.sock`
5. Change the ownership and permissions of the socket file: `sudo chown mysql:mysql /var/lib/mysql/mysql.sock` and `sudo chmod 660 /var/lib/mysql/mysql.sock`
6. Restart MySQL server: `sudo service mysql restart`
If none of these steps resolve the issue, it is possible that there is a problem with the MySQL configuration file. In this case, it may be necessary to consult the MySQL documentation or seek assistance from a knowledgeable MySQL administrator.