在连接Linux上的mysql时出现
Communications link failure due to underlying exception
...
Last packet sent to the server was 1 ms ago
...
这个是由于数据库连接超时造成的。需要修改mysql配置
打开
vi /etc/my.cnf找到
wait_timeout = 3030是默认超时时间,单位是秒
将30改为10年 315360000
wait_timeout = 315360000
然后重启mysql服务
service mysqld restart再试是否还有超时
本文介绍如何解决Linux环境下MySQL连接超时的问题。通过修改/etc/my.cnf文件中的wait_timeout参数来延长连接空闲超时时间,从而避免因连接超时导致的服务中断。
1万+

被折叠的 条评论
为什么被折叠?



