mysql: Communications link failure解决
来源:互联网 发布:阿里云服务器隐藏ip 编辑:程序博客网 时间:2024/05/16 14:13
mysql: Communications link failure解决
使用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将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
解决办法有两个:
一是修改my.cnf:
1)修改配置文件/etc/my.cnf(windows下my.ini),在[mysqld]下加两行interactive_timeout=设置值 wait_timeout=设置的值 然后重启mysql服务 service mysqld stop 命令 然后service mysqld start
或者是 service mysqld restart 再在sql里输入 show variables like '%timeout%' 查看这两个变量的值是不是改过来了
2)直接在sql命令行里设置 set global interactive_timeout=设置值 set global wait_timeout=设置值 这样的设置好像是只要一重启mysql服务 就会还原的
如:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
将过期时间修改为1年。
二是在连接URL上添加参数:&autoReconnect=true&failOverReadOnly=false
0 0
- mysql: Communications link failure解决
- mysql: Communications link failure解决
- 解决mysql:Communications link failure
- Mysql Communications link failure 问题的解决
- mysql: Communications link failure
- mysql Communications link failure
- communications link failure MySQL ibatis
- mysql异常:Communications link failure
- MySQL Communications link failure问题
- 解决com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- 解决com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- mysql 中Communications link failure的解决方法
- mysql 中Communications link failure的解决方法
- 数据库连接失败Communications link failure mysql
- com.mysql.jdbc.CommunicationsException: Communications link failure
- MySQL连接超时Communications link failure
- MySQL连接超时Communications link failure
- Mysql: Cannot create PoolableConnectionFactory (Communications link failure
- 好记性不如烂笔头——WebService与Remoting
- 女孩网上应聘高薪模特 被骗拍裸照后遭性侵
- 游标的简单用法
- 更改默认的mysql数据库目录
- Could not load the Tomcat server configuration at
- mysql: Communications link failure解决
- AsyncTask再度学习
- 下体的发挥
- mysql 数据库连接参数说明
- mahout数据源
- 获取联通、电信、任意ISP ip段
- JAVA并发(三)
- HDU(2037)贪心算法之时间序列
- 开发笔记之20140227