linux設(shè)置mysqlwait_timeout時間
查看MySQL5的手冊,發(fā)現(xiàn)對wait_timeout的最大值分別是24天/365天(windows/linux)。
以windows為例,假設(shè)我們要將其設(shè)為21天,我們只要修改MySQL5的配置文件“my.ini”(MySQL5 installation dir),
在[MySQLd]增加一行:wait_timeout=1814400
需要重新啟動MySQL5。
----------------------------------------------------------------
mysql修改wait_timeout
mysql mysql> show global variables like 'wait_timeout';
其默認(rèn)值為8小時
mysql的一個connection空閑時間超過8小時,mysql會自動斷開該連接。
1.修改配置(MySQL配置文件在Windows下叫my.ini,在MySQL的安裝根目錄下;在Linux下叫my.cnf,該文件位于/etc/my.cnf)
vi /etc/my.cnf
[mysqld] wait_timeout=10
# /etc/init.d/mysql restart
2.直接用sql命令行修改 mysql> set global wait_timeout=10;
mysql> show global variables like 'wait_timeout';
+----------------------------+-------+ | Variable_name
| Value | +----------------------------+-------+ | wait_timeout
| 10 | +----------------------------+-------+
show variables like '%time%';
timeBetweenEvictionRunsMillis = 20000 #dbcp每2000秒進(jìn)行一次connection的檢 minEvictableIdleTimeMillis = 28700 #每次檢驗(yàn)中將超過28700秒處于空閑的connection斷開
以windows為例,假設(shè)我們要將其設(shè)為21天,我們只要修改MySQL5的配置文件“my.ini”(MySQL5 installation dir),
在[MySQLd]增加一行:wait_timeout=1814400
需要重新啟動MySQL5。
----------------------------------------------------------------
mysql修改wait_timeout
mysql mysql> show global variables like 'wait_timeout';
其默認(rèn)值為8小時
mysql的一個connection空閑時間超過8小時,mysql會自動斷開該連接。
1.修改配置(MySQL配置文件在Windows下叫my.ini,在MySQL的安裝根目錄下;在Linux下叫my.cnf,該文件位于/etc/my.cnf)
vi /etc/my.cnf
[mysqld] wait_timeout=10
# /etc/init.d/mysql restart
2.直接用sql命令行修改 mysql> set global wait_timeout=10;
mysql> show global variables like 'wait_timeout';
+----------------------------+-------+ | Variable_name
| Value | +----------------------------+-------+ | wait_timeout
| 10 | +----------------------------+-------+
show variables like '%time%';
timeBetweenEvictionRunsMillis = 20000 #dbcp每2000秒進(jìn)行一次connection的檢 minEvictableIdleTimeMillis = 28700 #每次檢驗(yàn)中將超過28700秒處于空閑的connection斷開

浙公網(wǎng)安備 33010602011771號