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 ...
随机推荐
- Docker实战-编写Dockerfile
一.编译镜像 1. 编译镜像 Dockerfile类似于Makfile,用户使用docker build就可以编译镜像,使用该命令可以设置编译镜像时使用的CPU数量.内存大小.文件路径等 语法:doc ...
- 问题-MethodAddress返回NIL?MethodAddress与published的关系?
问题现象:有位朋友(397085381)在Q群里问“为什么书上的可以访问,而自己写的代码访问时为nil” 问题原因:因为要用“Self.MethodAddress('Test')”访问,方法必须放在“ ...
- 3. sklearn的K-Means的使用
1. K-Means原理解析 2. K-Means的优化 3. sklearn的K-Means的使用 4. K-Means和K-Means++实现 1. 前言 在机器学习中有几个重要的python学习 ...
- client version is higher than daemon version (client is v.1.29 daemon is v.1.22)
安装好coreseek,建了索引,启动了服务,用php建了一个test.php,用于测试:<?phpinclude_once('sphinxapi.php');//向搜索引擎发起请求 $cl = ...
- [文件]Linux文本处理常用命令总结
转自:https://www.cnblogs.com/sheeva/p/6406285.html 引子 作为一个偏爱windows的程序员,以前做文本处理的时候总是喜欢在windows下用notepa ...
- bower failed: UNABLE_TO_VERIFY_LEAF_SIGNATURE
.bowerrc配置 { "strict-ssl": false }
- maven配置阿里云仓库
在mirrors的节点中添加: <mirror> <!--This sends everything else to /public --> <id>nexus-a ...
- Android训练课程(Android Training) - 构建你的第一个应用
本文翻译自:https://developer.android.com/training/basics/firstapp/index.html 构建你的第一个应用(app) 欢迎来到安卓开发! 这个课 ...
- C/C++-STL中lower_bound与upper_bound的用法以及cmp函数
转载于:http://blog.csdn.net/tjpuacm/article/details/26389441 不加比较函数的情况: int a[]={0,1,2,2,3}; printf(&qu ...
- centos7配置kerberos服务,并使用JAAS登录
准备两个虚拟机:192.168.1.101.192.168.1.102,101作为kerberos的server端,102作为kerberos的client端.开启88端口. 1.安装kerberos ...