mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)
报错:
MySQL第二天早上第一次连接超时报错,
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
原因:
上述问题是由mysql5数据库的配置引起的。mysql5将其连接的等待时间(wait_timeout 、interactive_timeout)缺省为8小时。在其客户程序中可以这样来查看其值:
- mysql> show global variables like 'wait_timeout';
- mysql> SHOW GLOBAL VARIABLES LIKE 'interactive_timeout';
如果在wait_timeout秒期间内,数据库连接(java.sql.Connection)一直处于等待状态,mysql5就将该连接关闭。这时,你的Java应用的连接池仍然合法地持有该连接的引用。当用该连接来进行数据库操作时,就碰到上述错误。这解释了为什么我的程序第二天不能登录 的问题。
解决办法:
在my.ini(windows) 或者/etc/my.cnf(linux) 中的 [mysqld]下添加:
- wait_timeout=31536000
- interactive_timeout=31536000
如:
重启mysql再次查看超时设置:
- [root@iZbp12b0psb88pmxixiwcsZ /]# /etc/init.d/mysqld restart
...- mysql> SHOW GLOBAL VARIABLES LIKE 'interactive_timeout';
- +---------------------+----------+
- | Variable_name | Value |
- +---------------------+----------+
- | interactive_timeout | 31536000 |
- +---------------------+----------+
- 1 row in set (0.00 sec)
- mysql> show global variables like 'wait_timeout';
- +---------------+----------+
- | Variable_name | Value |
- +---------------+----------+
- | wait_timeout | 31536000 |
- +---------------+----------+
- 1 row in set (0.00 sec)
mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)的更多相关文章
- Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
很长的报错,截取 ERROR c.a.d.p.DruidDataSource - discard connection com.mysql.jdbc.exceptions.jdbc4.Comm ...
- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决
感谢大佬:https://blog.csdn.net/a704397849/article/details/93797529 springboot + mybatis多数据库 + druid连接池配置 ...
- 异常解决:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
异常描述 这个异常通常有如下信息: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failu ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法
09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...
- Oozie时出现Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure?
不多说,直接上干货! 问题详情 [hadoop@bigdatamaster oozie--cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -ru ...
- Caused by: java.net.ConnectException: Connection refused/Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
1.使用sqoop技术将mysql的数据导入到Hive出现的错误如下所示: 第一次使用命令如下所示: [hadoop@slaver1 sqoop--cdh5.3.6]$ bin/sqoop impor ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent succ
数据库 没有开启 连接失败 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause ...
- mysql连接com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
现象:客户端连接服务器端mysql是没问题的,所有都木有问题,应用程序配置也没问题,但是连接就抛异常: com.mysql.jdbc.exceptions.jdbc4.CommunicationsEx ...
随机推荐
- python 使用pillow将图片转换为webp格式
1.webp格式 webp格式是谷歌开发的一种旨在加快图片加载速度的格式,将图片转为webp格式后,体积约为原来的2/3,这可以节省大量的服务器带宽,微信公众号文章里的图片就是这种格式的. 2.使用p ...
- Eigen教程(9)
整理下Eigen库的教程,参考:http://eigen.tuxfamily.org/dox/index.html Eigen并没有为matrix提供直接的Reshape和Slicing的API,但是 ...
- [转]uboot中SPI Flash Booting配置
转自:https://e2echina.ti.com/question_answer/dsp_arm/sitara_arm/f/25/t/124834 最近和人一起调试SPI FLASH的配置问题,做 ...
- redis主从配置(docker实现)
一.docker新建两个redis服务端,并分别设置端口为6379和6380 命令如下: docker run -p : -d --name redis-server docker.io/redis: ...
- andorid——自定义seekbar(转)
xml 新建=>xml=>values <?xml version="1.0" encoding="utf-8"?> <resou ...
- 关于face alglimnment各种资料,存下来有空慢慢看
人脸对齐和应用 机器学习--详解人脸对齐算法SDM-LBF 基于MTCNN的人脸自动对齐技术原理及其Tensorflow实现测试 人脸检测——MTCNN CVPR论文<Face Alignmen ...
- asp.net cookie的操作
//写入 protected void Button2_Click(object sender, EventArgs e) { HttpCookie cookie=new Ht ...
- ansible普通用户su切换
[root@361way.com ~]# cat /etc/ansible/hosts [test01] 10.212.52.14 ansible_ssh_user=test ansible_ssh_ ...
- nfs挂载hdfs,实现云存储
本来不知道nfs是啥,因为群里的Harry童鞋有个问题,如何把本地目录挂载到hdfs上,搞什么云存储,说那么巧就是那么巧,HDP支持nfs,然后我就照着文档的说明去做,最后弄出来了. 1.修改机器上的 ...
- 【React全家桶入门之十】登录与身份认证
细致想想,我们的后台系统还没有一个登录功能,太不靠谱,赶紧把防盗门安上! SPA的鉴权方式和传统的web应用不同:因为页面的渲染不再依赖服务端,与服务端的交互都通过接口来完毕,而REASTful风格的 ...