无法连接到远程MySQL Server [英] Unable to connect to remote MySQL Server
问题描述
我有一台服务器试图连接到本地网络外部托管的MySQL数据库.我正在尝试使用公共IP地址连接到它.
I have a server attempting to connect to a MySQL database hosted outside of the local network. I am attempting to use a public IP address to connect to it.
在命令行中测试连接会给我这个错误:
Testing the connection in the command line gives me this error:
ERROR 2003 (HY000): Can't connect to MySQL server on '[ip_address]' (146)
PDO给了我同样的错误.无论如何,该连接在本地和同一网络中都可以正常工作,这让我感到困惑.
PDO gives me the same error. In any case, the connection works fine locally and within the same network, which is what boggles my mind.
MySQL服务器的绑定地址已修改,因此它接受远程连接. MySQL服务器还为用户设置了适当的权限.但是无论如何,似乎我一开始都无法启动连接.
The MySQL server has had its bind-address modified so it accepts remote connections. The MySQL server also has a user with the proper privileges set. But in any case, it looks as though I can't even start the connection in the first place.
是否需要添加my.cnf值以使MySQL接受来自本地网络外部的请求?
Is there a my.cnf value I need to add to let MySQL accept requests from outside the local network?
谢谢.
推荐答案
要检查的内容:
- MySQL正在使用公共IP进行监听(听起来像您所做的一样)
- MySQL正在标准端口上监听/您正在连接正在监听的端口.
- 远程计算机上是否运行防火墙? (它们通常是发行版的标准包装).防火墙是否配置为允许连接到该端口?
- 如果远程计算机位于另一个网络中,则连接和终端计算机之间是否正在进行网络地址转换(NAT)-如果是,则将其配置为允许MySQL端口通过.
-
my.cnf
文件是否配置为允许来自localhost
127.0.0.1
IP以外的任何其他地址的连接-尽管您更有可能获得访问被拒绝的响应,而不是无法连接.
- MySQL is listening on public IP (sounds like you've done)
- MySQL is listening on standard port / you're connecting the same port it's listening to.
- Is there a firewall running on the remote machine? (They usually are packaged standard in distros) Is the firewall configured to allow connections to that port?
- If the remote machine is within another network, is there network address translation (NAT) going on between your connection and the end machine - if so, is it configured to allow the MySQL port through.
- Is the
my.cnf
file configured to allow connections from anything other thanlocalhost
127.0.0.1
IPs - although you'd more likely get a access denied response, than a cannot connect.
这篇关于无法连接到远程MySQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!