在“读取初始通信数据包"时失去与 MySQL 服务器的连接,系统错误:0 [英] Lost connection to MySQL server at 'reading initial communication packet', system error: 0

查看:67
本文介绍了在“读取初始通信数据包"时失去与 MySQL 服务器的连接,系统错误:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:

在读取初始通信数据包时失去与 MySQL 服务器的连接,系统错误:0"

"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"

当我要连接我的数据库时.

while I am going to connect my db.

如果我使用 localhost 一切正常.但是,当我使用如下所示的实时 IP 地址时,出现错误:

If I am using localhost everything is working fine. But when I am using my live IP address like below, it's getting error:

mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());

推荐答案

某人 此处 表明这可能是防火墙问题:

Someone here suggests that it might be a firewall problem:

我刚遇到这个问题,发现是我的防火墙造成的.我使用 PCTools Firewall Plus 并且它不允许完全访问 MySQL.一旦我改变它就好了.希望有所帮助.

I have just had this problem and found it was my firewall. I use PCTools Firewall Plus and it wasn't allowing full access to MySQL. Once I changed that it was fine. Hope that helps.

可以吗?

另外,有人这里 暗示它可能因为 MySQL 服务器绑定到环回 IP (127.0.0.1/localhost),这有效地切断了您与外部"的连接.

Also, someone here suggests that it might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside".

如果是这种情况,您需要将脚本上传到网络服务器(它可能也在运行 MySQL 服务器)并将您的服务器主机保持为本地主机"

If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost'

这篇关于在“读取初始通信数据包"时失去与 MySQL 服务器的连接,系统错误:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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