错误Communications link failure,The last packet successfully received from the server was的解决方法
来源:互联网 发布:产品经理用app 知乎 编辑:程序博客网 时间:2024/05/16 16:04
原文链接:http://blog.csdn.net/mqboss/article/details/6659001
最近做测试,发现Mysql 过一段时间会无法连接,导致数据库数据不一至,极其郁闷。
使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误:
Communications link failure,The last packet successfully received from the server was *** millisecond ago.The last packet successfully sent to the server was *** millisecond ago。
其中错误还会提示你修改wait_timeout或是使用Connector/J的autoReconnect属性避免该错误。
后来查了一些资料,才发现遇到这个问题的人还真不少,大部分都是使用连接池方式时才会出现这个问题,短连接应该很难出现这个问题。这个问题的原因:
MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
1.按照错误的提示,可以在JDBC URL中使用autoReconnect属性,实际测试时使用了autoReconnect=true&failOverReadOnly=false,不过并未起作用,使用的是5.1版本,可能真像网上所说的只对4之前的版本有效。
2.没办法,只能修改MySQL的参数了,wait_timeout最大为31536000即1年,在my.cnf中加入:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
- 错误Communications link failure,The last packet successfully received from the server was的解决方法
- Communications link failure,The last packet successfully received from the server was *** millisecon
- Communications link failure,The last packet successfully received from the server was *** millisecon
- MYSQL Communications link failure,The last packet successfully received from the server was
- Communications link failure,The last packet successfully received from the server was × millisecon..
- Communications link failure,The last packet successfully received from the server was *** millisecon
- Communications link failure,The last packet successfully received from the server was *** millisecon
- mysql 报错Communications link failure,The last packet successfully received from the server was × mill
- 数据库学习笔记(十)Communications link failure,The last packet successfully received from the server was
- MySQL: Communications link failure,The last packet successfully received from the server
- Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
- Communications link failure:The last packet sent successfully to the server was 0 milliseconds ago.
- (2)Mysql ----- The last packet successfully received from the server was *** millisecond ago.The
- 关于Communications link failure Last packet sent to the server was 0 ms ago.的解决办法
- The last packet successfully received from the server was XXX seconds ago
- mysql The last packet successfully received from the server was XXX seconds ago
- 彻底解决"The last packet successfully received from the server was * milliseconds ago"问题
- The last packet successfully received from the server was 78,682,686 milliseconds ago
- Esri携“新一代Web GIS”亮相中国地理信息产业大会
- 在Oracle中存储图片、影像等大文件
- 常用的渗透测试工具型网站
- MapReduce and MPP: Two sides of the Big Data coin?
- 程序设计作业报告项目一
- 错误Communications link failure,The last packet successfully received from the server was的解决方法
- 数值转换工具 TypedValue ---屏幕单位转换 (笔记 )
- 统计整数二进制表示中1的个数
- 流读取数据的时候字符乱码的终极解决办法。
- 大精进
- CentOS 64位系统下 PHP 5.3.3 启动 php-fpm 功能的安装
- 泡沫对话框
- Orace数据库锁表的处理与总结<摘抄与总结一>
- android 4.4 信息设置默认