无法使用外部ip地址连接到MySQL数据库 [英] can't connect to MySQL database using external ip address

查看:256
本文介绍了无法使用外部ip地址连接到MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL服务器作为Windows服务在我的Windows 7计算机上运行。当我尝试使用 external.ip =我的IP地址从 http://www.whatismyip.com连接到它/

I have a MySQL server running on my Windows 7 computer as a Windows Service. When I try to connect to it using external.ip = my ip address from http://www.whatismyip.com/ in command prompt:

mysql -h external.ip -u root -p

它返回:

ERROR 2003 (HY000): Can't connect to MySQL server on external.ip (10060)

但是,当我将 external.ip 更改为使用 ipconfig 命令列出的IP地址时,我可以将其连接到它:

I can, however, connect it to it when I change external.ip to the ip address listed with the ipconfig command:

mysql -h ipconfig.ip -u root -p

我已经更改root的权限以接受任何主机(使用来自)。在数据库中:

I already changed the permissions for root to accept any host (using commands like those from Accessing a mysql database from external host/ip? (ie: mysql workbench)). In the database:

SELECT host, user FROM user;

返回(总结):

| host   | user |
-----------------
| %      | root |

此外,在我的my.ini文件中,没有表示skip-networking的行。

Also, in my my.ini file, there is no line that says skip-networking.

当我在其他日子尝试这个工作正常,其中 external.ip ipconfig.ip

It worked fine when I tried this the other day on a different network where external.ip was the same as ipconfig.ip. Could this be the source of the problem or is there something else?

推荐答案

如果 http://www.whatismyip.com/ 和你从ipconfig获得的地址是不同的,这意味着你使用本地路由器(可能是一个使用连接到互联网)网络地址转换。换句话说,你有一个本地网络(在你家或你的互联网咖啡馆),它有192.168.0.1或10.0.0.1等专用网络地址。

If http://www.whatismyip.com/ and the address you get from ipconfig are different, that means you're using a local router (probably the one you use to connect to the internet) that network address translation. In other words, you have a local network (in your house or your fav internet cafe) that has private-network addresses like 192.168.0.1 or 10.0.0.1.

MySQL通常使用在端口3306上侦听入站连接请求。但是,当您尝试通过您的公共IP地址(我的IP地址是什么)连接时,您的网络提供商将请求发送到您的路由器。路由器通知端口3306,但它可能不知道该怎么做。所以它默默地忽略请求。您用来建立连接的软件会超时。这是好的。 Crackers尝试连接到这样的端口,看看他们是否可以进入你的机器。

MySQL usually uses listens on port 3306 for inbound connection requests. But, when you try to connect via your public ip address (the What's My IP address) your network provider sends the request to your router. The router notices port 3306, but it probably doesn't know what to do with it. So it silently ignores the request. The software you're using to make the connection then times out. This is good. Crackers try to connect to ports like that to see if they can get into your machine.

因此,要让这个工作,你需要配置你的路由器传入的TCP请求端口3306到运行您的MySQL服务器的机器。它可能有一个配置屏幕来做到这一点。它将在您拥有的路由器上工作。

So, to get this to work you need to configure your router to pass incoming TCP requests to port 3306 through to the machine that runs your MySQL server. It probably has a configuration screen to do this. It will work on the router you own. It won't work on the coffee shop router.

如果您不确定端口是什么意思,或者为什么从ipconfig获取不同的IP地址, http://www.whatismyip.com/ ,您可能需要更多地了解互联网技术,你应该尝试这种事情。

If you're not sure what "port" means, or why you get a different IP address from ipconfig and from http://www.whatismyip.com/, with respect you probably need to learn quite a bit more about internet technology before you should attempt this kind of thing.

这篇关于无法使用外部ip地址连接到MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆