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

编程入门 行业动态 更新时间:2024-10-27 02:28:07
本文介绍了在“读取初始通信数据包"时失去与 MySQL 服务器的连接,系统错误:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我收到错误:

在读取初始通信数据包时失去与 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-15 13:13:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/865705.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据包   错误   通信   服务器   系统

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!