Error: Unable to Connect to Local MySQL Server
Initial Situation
The problem arose when an attempt to reset the MySQL root password using mysqld_safe --skip-grant-tables failed, resulting in the error message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Troubleshooting Attempts
Upon investigation, it was discovered that the /var/run/mysqld/mysqld.sock socket file was missing. Following unsuccessful attempts to resolve the issue, the MySQL packages were uninstalled and reinstalled.
Reinstallation Issue
During the PHPMyAdmin installation after the reinstall, the same error occurred:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Manual File and Directory Renaming
To mitigate the issue, all MySQL files and directories were manually renamed to mysql.bad. Upon attempting to reinstall MySQL, it was noted that it did not prompt for an admin password.
Solution
To resolve the error and start the MySQL server, try executing the following command:
sudo service mysql start
The above is the detailed content of Why Can't I Connect to My Local MySQL Server After Reinstallation?. For more information, please follow other related articles on the PHP Chinese website!