Home > Database > Mysql Tutorial > Why Can't I Connect to My Remote MySQL Server (Error 111)?

Why Can't I Connect to My Remote MySQL Server (Error 111)?

Linda Hamilton
Release: 2024-12-18 17:23:15
Original
228 people have browsed it

Why Can't I Connect to My Remote MySQL Server (Error 111)?

Troubleshooting Error 111: Connecting to a Remote MySQL Server

You've encountered an issue while attempting to connect to a MySQL server hosted on a remote machine, receiving the error message "Can't connect to MySQL server on '[IP address]' (111)." This error typically indicates that the MySQL server is not listening on the network interface, preventing external connections.

Difference Between Localhost/127.0.0.1 and Remote IP Address

Localhost and 127.0.0.1 refer to the local machine. When connecting using these addresses, the connection attempt directly targets the database server running on the same system. However, when using the remote IP address (192.168.1.100), the connection is routed through the network interface, which requires additional configuration.

Resolution

To resolve this issue, you must ensure that the MySQL server is configured to listen on the network interface. Edit the my.cnf configuration file and locate the following lines:

bind-address = 127.0.0.1
Copy after login

If these lines exist, uncomment them by removing the # symbol at the beginning. This will allow the MySQL server to listen on all network interfaces, including the one with the remote IP address.

After making these changes, restart the MySQL server using the following command:

sudo service mysql restart
Copy after login

This will reread the configuration file and apply the changes. Now, you should be able to connect to the MySQL server from both the local machine and the remote machine using the remote IP address.

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