热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

mysql20132006_mysql官方关于2013和2006错误代码产生原因和解决方案_MySQL

一、错误代码Error:2013(CR_SERVER_LOST)Message:LostconnectiontoMySQLserverduringqueryError:2006(C

一、错误代码

Error: 2013 (CR_SERVER_LOST)

Message: Lost connection to MySQL server during query

Error: 2006 (CR_SERVER_GONE_ERROR)

Message: MySQL server has gone away

二、错误代码原因

错误代码

描述

CR_SERVER_GONE_ERROR

客户端无法向服务器发送请求

CR_SERVER_LOST

当向服务器写入时无法获取错误,但无法获取请求的完整应答。

主要原因和解决办法:

By default, the server closes the connection after eight hours if nothing has happened. You can change the time limit by setting the wait_timeout variable when you start mysqld.

默认服务器在8小时后关闭连接,可以通过参数wait_timeout,然后重启mysqld服务来修改默认值。

If you have a cript:, you just have to issue the query again for the client to do an automatic reconnection. This assumes that you have automatic reconnection in the client enabled (which is the default for the mysql command-line client).

如果你使用脚本,你只能在客户端重新连接再查询。这种情况你必须打开客户端重连接。

Some other common reasons for the MySQL server has gone away error are:

引起MySQL server has gone away错误的其它常见原因:

You (or the db administrator) has killed the running thread with a KILL statement or a mysqladmin kill command. 人为杀掉查询进程。

You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected. 服务器关闭连接后,试图向服务器发送查询,这表明必须修改应用逻辑错误。

A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host. 客户端应用运行不同主机,连接至 mysql的主机没有必要的权限。

You got a timeout from the TCP/IP connection on the client side. This may happen if you have been using the commands: mysql_options(..., MYSQL_OPT_READ_TIMEOUT,...) or mysql_options(..., MYSQL_OPT_WRITE_TIMEOUT,...). In this case increasing the timeout may help solve the problem. 客户端TCP/IP连接超时,这可能是使用了mysql选项引起的,这种情况增加超时时间可以帮助解决问题。

You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0). 服务器端连接超时和客户端自动重连被关闭

You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.

如果你使用Windows客户端,命令发送前服务器就已经删除连接(可能是因为wait_timeout已经过期)

The problem on Windows is that in some cases MySQL doesn't get an error from the OS when writing to the TCP/IP connection to the server, but instead gets the error when trying to read the answer from the connection.

在windows平台,一些情况是MySQL通过TCP/IP连接至服务器时无法从系统级获取错误,而是当从连接试图读取应答时获取错误。

Prior to MySQL 5.1.8, even if the reconnect flag in the MYSQL structure is equal to 1, MySQL does not automatically reconnect and re-issue the query as it doesn't know if the server did get the original query or not.

在5.18以前的版本,尽管重连标志在mysql架构是1,但mysql不能自动重连和重新执行查询,因为它不知道服务器获取的查询是否是原始发送的。

The solution to this is to either do a mysql_ping() on the connection if there has been a long time since the last query (this is what MyODBC does) or set wait_timeout on the mysqld server so high that it in practice never times out.

这种情况的解决方案就是用mysql_ping()连接确认自上次以为是否有长时间查询(MyODBC原理)。或者设置wait_timeout参数为很高的值,使连接不可能超时。

You can also get these errors if you send a query to the server that is incorrect or too large. If mysqld receives a packet that is too large or out of order, it assumes that something has gone wrong with the client and closes the connection. If you need big queries (for example, if you are working with big BLOB columns), you can increase the query limit by setting the server's max_allowed_packet variable, which has a default value of 1MB. You may also need to increase the maximum packet size on the client end.

向服务器发送不正确或者太大的查询也会导致这种错误。如果mysqld收到的包太大或者无序,它就认为客户端发生错误而断开连接。如果需要大查询,可以修改max_allowed_packet变量,该变量默认值是1M。在客户端也需要设置最大包的大小。

An INSERT or REPLACE statement that inserts a great many rows can also cause these sorts of errors. Either one of these statements sends a single request to the server irrespective of the number of rows to be inserted; thus, you can often avoid the error by reducing the number of rows sent per INSERT or REPLACE.

INSERT or REPLACE语句插入大量的行也会引起这种错误。这些语句不考虑插入的行数而发送单一的请求至服务器。因此,减少插入的行数可以避免经常发生这种错误。

You also get a lost connection if you are sending a packet 16MB or larger if your client is older than 4.0.8 and your server is 4.0.8 and above, or the other way around.

如果客户端是4.0.8以前的版本而服务器是4.0.8以上的版本,当你发送16M以上的包时也会断开连接

It is also possible to see this error if host name lookups fail (for example, if the DNS server on which your server or network relies goes down). This is because MySQL is dependent on the host system for name resolution, but has no way of knowing whether it is working — from MySQL's point of view the problem is indistinguishable from any other network timeout.

如果解析主机名失败也可能看到这种错误。这是因为mysql依赖于主机系统解析主机名,但无法知道它是否有效。以mysql观点来看,在任何网络超时中这种情况都是不易察觉的。

You may also see the MySQL server has gone away error if MySQL is started with the --skip-networking option.

可以尝试使用--skip-networking来启动mysql.

Another networking issue that can cause this error occurs if the MySQL port (default 3306) is blocked by your firewall, thus preventing any connections at all to the MySQL server.

其中网络问题也会导致这种情况,如果mysql 3306端口被防火墙阻塞,就阻止了连接到mysql的任何连接。

You can also encounter this error with applications that fork child processes, all of which try to use the same connection to the MySQL server. This can be avoided by using a separate connection for each child process.

如果应用产生子进程,所有子进程都试图使用同样的连接至mysql服务器,也同样会出现这种错误。可以把不同的子进程用不同的连接来避免这种问题。

You have encountered a bug where the server died while executing the query.

执行查询时,服务器进程已经死掉,这是遇到的bug.

You can check whether the MySQL server died and restarted by executing mysqladmin version and examining the server's uptime. If the client connection was broken because mysqld crashed and restarted, you should concentrate on finding the reason for the crash. Start by checking whether issuing the query again kills the server again.

你可以检查mysql服务是否已经死掉,执行重启和检查服务器启动时间。如果客户端连接中断是因为mysqld崩溃和重启,可以集中查找mysql崩溃的原因。

f68f2add0b68e4f9810432fce46917b7.png

相关标签:

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

相关文章

相关视频



推荐阅读
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • Google Play推出全新的应用内评价API,帮助开发者获取更多优质用户反馈。用户每天在Google Play上发表数百万条评论,这有助于开发者了解用户喜好和改进需求。开发者可以选择在适当的时间请求用户撰写评论,以获得全面而有用的反馈。全新应用内评价功能让用户无需返回应用详情页面即可发表评论,提升用户体验。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
author-avatar
爱心常在V_991
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有