Home > Database > Mysql Tutorial > Why Can't I Connect to My MySQL Server on '127.0.0.1'?

Why Can't I Connect to My MySQL Server on '127.0.0.1'?

Susan Sarandon
Release: 2024-12-12 21:56:21
Original
256 people have browsed it

Why Can't I Connect to My MySQL Server on '127.0.0.1'?

MySQL Connection Error: "Can't connect to MySQL server on '127.0.0.1'

Issue:

Upon executing the command mysql -u root -h 127.0.0.1 -p, you encounter the following error message:

ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Copy after login

Resolution:

In Ubuntu systems, this error can be resolved by performing the following steps:

  1. Edit the MySQL configuration file:

    • Open the file /etc/mysql/my.cnf using a text editor (e.g., vim).
  2. Comment out the bind-address parameter:

    • Locate the line that begins with bind-address = 127.0.0.1 and comment it out by adding a # symbol to the beginning of the line.
  3. Restart the MySQL server:

    • Restart the MySQL server to apply the changes.

Note: If you are using a different operating system or if the error occurs on a MySQL server with replication enabled, you may need to adjust the bind-address parameter or use an alternative method to establish the connection.

The above is the detailed content of Why Can't I Connect to My MySQL Server on '127.0.0.1'?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template