Home > Database > Mysql Tutorial > Why Can't I Connect to My Local MySQL Server After Reinstallation?

Why Can't I Connect to My Local MySQL Server After Reinstallation?

DDD
Release: 2024-12-26 18:15:15
Original
768 people have browsed it

Why Can't I Connect to My Local MySQL Server After Reinstallation?

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)'
Copy after login

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)
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template