Home >Database >Mysql Tutorial >MySQL空闲连接超时错误

MySQL空闲连接超时错误

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:01:261218browse

MySQL服务器默认的ldquo;wait_timeoutrdquo;是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时

MySQL服务器默认的“wait_timeout”是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,MySQL将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。

如此后链接则提示错误:com.MySQL.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.

查看MySQL5的手册,发现对wait_timeout的最大值分别是24天/365天(windows/linux)。以windows为例,,假设我们要将其设为21天,我们只要修改MySQL5的配置文件“my.ini”(MySQL5 installation dir),在[MySQLd]增加一行:wait_timeout=1814400

需要重新启动MySQL5。

linux

Statement:
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