2024年4月17日发(作者:)
关于MySQL的wait_timeout连
接超时问题报错解决方案
关于MySQL的wait_timeout连接超时问题报错解决方案
Mysql服务器默认的“wait_timeout”是8小时【也就是默认的值默认是28800
秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该
connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连
接。
wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约
24.85天
所以即使你MySQL通过 在
# The TCP/IP Port the MySQL Server will listen on
port=3306下面添加
# this is myown dinifition for mysql connection timeout
wait_timeout=31536000
interactive_timeout=31536000
无论超过最大限度多大的数值,只能被MySQL解析为2147483,2147483天后你
的程序该出什么错还是什么错,避免不了的
在说这个错误之前先说明我的项目是通过Hibernate来进行数据库操作的
关于MySQL连接超时问题,估计很多人都遇到过:大致情形都是这样,开发测
试时程序都是正常的,一到第二天就出先莫名错误,比如在我的项目中就是定
时任务执行,每天凌晨一点执行一次,也就是24小时每隔24小时执行,远远
超出了8小时
如果你刚好在数据库超时的第一时间内看到日志记录的话那么,第一次超时发
生的错误就是这样的:
ERROR [ceptionReporter] - Communications link
failure
Last packet sent to the server was 0 ms ago.
如果不是第一次超时后执行,以后每次报错就变成嵌套的错误了,就是下面这
样:
ERROR [ceptionReporter] -
No operations allowed after connection tion was
implicitly closed due to underlying exception/error:
** BEGIN NESTED EXCEPTION **
icationsException
MESSAGE: The last packet successfully received from the server was86395
milliseconds last packet sent successfully to the server was
86395 milliseconds ago, which is longer than the server configured
发布者:admin,转转请注明出处:http://www.yc00.com/web/1713342436a2229963.html
评论列表(0条)