Home > Database > Mysql Tutorial > mysql 默认8小时 链接超时 解决办法

mysql 默认8小时 链接超时 解决办法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:15:17
Original
1407 people have browsed it

mysql 默认8小时 链接超时 解决方法 整理了几种解决方法,仅供参考。 ? 1. 在数据库链接字符串中添加参数: (省略前面的)autoReconnect=true ? 注 :mysql 5 之前的有效。 ? 2.通过sql语句修改'wait_timeout'的值(需要重启mysql服务器): use mysql; -- 在mys

mysql 默认8小时 链接超时 解决方法

整理了几种解决方法,仅供参考。

?

1.在数据库链接字符串中添加参数:
(省略前面的)&autoReconnect=true

?

:mysql 5 之前的有效。

?

2.通过sql语句修改'wait_timeout'的值(需要重启mysql服务器):
use mysql; -- 在mysql库下。
SHOW GLOBAL VARIABLES LIKE 'wait_timeout'; -- 查看当前值。
SET GLOBAL wait_timeout = 1814400; -- 修改(这里为21天单位秒)。

?

:也可以通过修改mysql配置文件进行修改(windows-my.ini;linux-my.cnf)

?

3.用定时任务定时查询数据库:
(1)如项目用的是spring,可以用spring之quartz定时任务。
(2)如果项目中用的hibernate,注意清理缓存问题。

?

4.通过修改相应连接池配置来解决:
(1)如使用c3p0连接池等。

?

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template