LoginSignup
74
71

More than 5 years have passed since last update.

MySQL の wait_timeout を変更。

Last updated at Posted at 2013-12-18

接続維持時間をデフォルトの 8 時間から 1 分に変更。
この設定、接続のアイドル状態が一定時間続くと MySQL 側から自動的に接続を切る設定らしい。

うかつに低く設定すると、バッチ処理とかのときに考慮が必要になりそう。

稼働中のサーバで変更。

> set global wait_timeout=60;
> show global variables like '%wait%';
+---------------------------------------------------+----------+
| Variable_name                                     | Value    |
+---------------------------------------------------+----------+
| innodb_lock_wait_timeout                          | 120      |
| innodb_spin_wait_delay                            | 6        |
| lock_wait_timeout                                 | 31536000 |
| performance_schema_events_waits_history_long_size | 10000    |
| performance_schema_events_waits_history_size      | 10       |
| wait_timeout                                      | 60       |
+---------------------------------------------------+----------+
6 rows in set (0.00 sec)

my.cnf に書く場合こんな感じ。

[mysqld]
wait_timeout = 60
74
71
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
74
71