Home > Database > Mysql Tutorial > Why Can't I Connect to My MySQL Server from a Remote Machine (Error 111: Connection Refused)?

Why Can't I Connect to My MySQL Server from a Remote Machine (Error 111: Connection Refused)?

DDD
Release: 2024-12-16 21:16:11
Original
133 people have browsed it

Why Can't I Connect to My MySQL Server from a Remote Machine (Error 111: Connection Refused)?

Can't Connect to MySQL Server Error 111: Connections Restricted to Localhost

The error "Can't connect to MySQL server on '192.168.1.100' (111)" suggests that your MySQL server is only accepting connections from the localhost interface. This means that you can connect to the database from the local machine itself (using 'localhost' or '127.0.0.1'), but not from other machines on the network.

Difference between localhost/127.0.0.1 and 192.168.1.100

  • localhost: Refers to the local machine and resolves to the IP address 127.0.0.1. It allows connections from the local machine itself.
  • 127.0.0.1: Is the IPv4 loopback address, which represents the local machine. It is equivalent to 'localhost' for connection purposes.
  • 192.168.1.100: Is the external IP address of the machine where MySQL is installed. It allows connections from other machines on the network.

Solution

To enable connections from other machines,你需要修改my.cnf配置文件并取消注释bind-address选项。

  1. 编辑my.cnf配置文件:
sudo vi /etc/mysql/my.cnf
Copy after login
  1. 取消注释bind-address选项:
#bind-address = 127.0.0.1
Copy after login
  1. 保存修改并重启MySQL服务:
sudo service mysql restart
Copy after login

After restarting MySQL, you will be able to connect to the database from other machines using the external IP address (192.168.1.100).

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