Home > Database > Mysql Tutorial > Why Am I Getting MySQL Error 111: Can't Connect to MySQL Server?

Why Am I Getting MySQL Error 111: Can't Connect to MySQL Server?

DDD
Release: 2024-12-17 04:15:25
Original
359 people have browsed it

Why Am I Getting MySQL Error 111: Can't Connect to MySQL Server?

Connecting to MySQL Server: Understanding Error 111

Connecting to a MySQL server from a remote machine can sometimes result in an "Error 111: Can't connect to MySQL server" message. This error indicates that the client cannot establish a connection with the server.

Difference between localhost/127.0.0.1 and External IP

In the given scenario, the MySQL server is only listening on the localhost interface (127.0.0.1). When using localhost or 127.0.0.1, the client and server are essentially on the same machine, allowing for direct communication.

On the other hand, connecting to the server's external IP address (192.168.1.100) requires the client to establish a connection over the network. If the MySQL server is not configured to listen on all interfaces, it will only accept connections from the local machine.

Solution

To resolve this issue, you need to edit the MySQL configuration file (my.cnf) and uncomment the following lines:

bind-address = 127.0.0.1
Copy after login

By uncommenting these lines, you are allowing the MySQL server to listen on all interfaces. Once this is done, restart MySQL:

sudo service mysql restart
Copy after login

Now, you should be able to connect to the MySQL server from both the local and remote machines without encountering Error 111.

The above is the detailed content of Why Am I Getting MySQL Error 111: Can't Connect to MySQL Server?. 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