连接mysql数据库出现The last packet sent successfully to the server was 0 milliseconds ago.问题解决方案

使用连接池访问mysql数据库查询列表数据出现

我的mysql版本是5.5.62

Communications link failure,The last packet successfully received from the server was 0 millisecond ago.The last packet successfully sent to the server was 0  millisecond ago报错

我的情况是列表查询出来不一会儿就会出现报错,而且是持续报一样The last packet sent successfully to the server was 0 milliseconds ago的错误

我的解决办法

在mysql下的my.ini文件(在mysql安装路径下)中添加配置

连接mysql数据库出现The last packet sent successfully to the server was 0 milliseconds ago.问题解决方案_第1张图片

问题解决

[mysqld] 
wait_timeout=31536000 
interactive_timeout=31536000

但这只能并没有解决根本问题........

因为这个是关于MySQL的wait_timeout连接超时问题报错

 

具体解释是这样的:Mysql服务器默认的“wait_timeout”是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。
wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约24.85天
所以即使你MySQL通过my.ini 在
# 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,24天后你的程序该出什么错还是什么错,避免不了的

如果大家有什么好的解决思路可以在评论留言哦~

 

 

 

 

你可能感兴趣的:(编程日记记录,bug记录)