MySQL 错误 2013

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1011911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:32:07  来源:igfitidea点击:

MySQL Error 2013

mysqlmysql-error-2013

提问by

I am facing connection failure to MySQL problem when I run my program for more than couple of days.MySQL Error Code is 2013 while connecting to Database. MySQL server and client programs are both on same machine. I am using FC5 as my OS and MySQL version is 5.0.18. Can anybody throw some light on this?

当我运行我的程序超过几天时,我面临连接到 MySQL 的问题。连接到数据库时 MySQL 错误代码是 2013。MySQL 服务器和客户端程序都在同一台机器上。我使用 FC5 作为我的操作系统和 MySQL 版本是 5.0.18。有人可以对此有所了解吗?

I am getting mysql error 2013 while calling mysql_real_connect()...

我在调用时收到 mysql 错误 2013 mysql_real_connect()...

Any help is appreciated.

任何帮助表示赞赏。

回答by spap

Try using localhost, instead of your own IP. I don't know why, but this immediately fixed the problem for me.

尝试使用 localhost,而不是您自己的 IP。我不知道为什么,但这立即为我解决了问题。

I would be very grateful if someone could clarify why this worked, all of a sudden.

如果有人能突然澄清为什么这会奏效,我将不胜感激。

回答by VVS

  1. Sounds like a firewall issue. Have you tried disabling the firewall temporarily?

  2. Another possible solution involves edition the startup script as mentioned hereand commenting out the following line:

    SKIP=skip-networking

  3. A third possible solution is mentioned here. The user tried to access an InnoDB database and InnoDB support was accidentially deactivated for the MySQL server.

  4. (new)I found this official MySQL articlewhich has lots of approaches to solve the problem. Did you modify the wait_timeout system variable?

  1. 听起来像是防火墙问题。您是否尝试过暂时禁用防火墙?

  2. 另一种可能的解决方案涉及编辑此处提到的启动脚本并注释掉以下行:

    SKIP=跳过网络

  3. 这里提到第三种可能的解决方案。用户尝试访问 InnoDB 数据库,并且意外禁用了 MySQL 服务器的 InnoDB 支持。

  4. (新)我发现了这篇 MySQL 官方文章,其中有很多解决问题的方法。您是否修改了 wait_timeout 系统变量?

回答by Boot Zero

Here's an answer you might not expect. I had encountered the same problem. MySQL Error 2013. Here are the symptoms:

这是您可能意想不到的答案。我遇到了同样的问题。MySQL 错误 2013。以下是症状:

  1. PHPMyAdmin fired off 2013 and error 95.

  2. I could shell into the MySQL monitor, but it took an inordinately long time to start. I could view tables and everything worked once the command line utility started

  3. The server took a LONG time to stop and restart.

  4. No errors in the MySQL error log.

  1. PHPMyAdmin 触发了 2013 和错误 95。

  2. 我可以用 shell 进入 MySQL 监视器,但它花了非常长的时间来启动。一旦命令行实用程序启动,我就可以查看表格并且一切正常

  3. 服务器花了很长时间停止和重新启动。

  4. MySQL 错误日志中没有错误。

I work with a good sysadmin who checked netstat -tn, which yielded the answer:

我与一位检查过 netstat -tn 的优秀系统管理员合作,得到了答案:

tcp        0      0 [my.srv.ip]:3306     184.73.87.215:59271     ESTABLISHED
tcp        0      1 [my.srv.ip]:38138    184.73.87.215:113       SYN_SENT

The IP resolves to Amazon Web Services. Some prick was leeching onto my 3306, even though everything but port 80 is allow-only. It's time to review my firewall rules.

IP 解析为 Amazon Web Services。尽管端口 80 以外的所有端口都是允许的,但我的 3306 上还是有一些问题。是时候检查我的防火墙规则了。

There were no new tables, and mtop didn't show any activity, but I found a ton of these in the auth log:

没有新表,并且 mtop 没有显示任何活动,但我在身份验证日志中发现了大量这些:

Apr 19 15:14:52 magic2 mysqld[18953]: refused connect from ec2-184-73-87-215.compute-1.amazonaws.com
Apr 19 15:18:02 magic2 mysqld[18953]: refused connect from ec2-184-73-87-215.compute-1.amazonaws.com

After blocking the offending IP in iptables, the problem suddenly went away. Sneaky Bastards. The moral of this story is: What looks like bug, might be a hacker.

在 iptables 中阻止违规 IP 后,问题突然消失了。狡猾的混蛋。这个故事的寓意是:看起来像 bug 的,可能是黑客。

bz

bz

回答by Dennis Day

Check your my.cnf. Set your bind-address to the server's IP address. Solved the issue for me. NO ONE seemed to know the answer to that one!

检查您的 my.cnf。将您的绑定地址设置为服务器的 IP 地址。为我解决了这个问题。似乎没有人知道答案!

回答by Alex Joe

My fix was - change 'localhost' to '127.0.0.1'

我的解决方法是 - 将 'localhost' 更改为 '127.0.0.1'

回答by Haim Evgi

It could be a network error that caused the TCP/IP connection to drop, or the wait_timeout was exceeded on the server; the latter can actually be useful in keeping the # of open connections down, but the app will then need to handle errorcode 2013 correctly!!

可能是网络错误导致 TCP/IP 连接断开,或者服务器上超过了 wait_timeout;后者实际上在保持打开连接数下降方面很有用,但应用程序随后需要正确处理错误代码 2013!