在“读取初始通信数据包"时与MySQL服务器的连接断开,系统错误:0 [英] Lost connection to MySQL server at 'reading initial communication packet', system error: 0
问题描述
我遇到错误:
在读取初始通信数据包时与MySQL服务器的连接丢失,系统错误:0"
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
在我连接数据库时.
如果我使用本地主机,则一切正常. 但是,当我使用如下所示的实时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".
在这种情况下,您需要将脚本上传到Web服务器(该服务器可能也正在运行MySQL服务器),并将服务器主机保持为"localhost"
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屋!