mysqld will timeout DB Connections based on two(2) server options:
- interactive_timeout
- wait_timetout
Both are 28800 seconds (8 hours) by default.
You can set these options in /etc/my.cnf
If your connections are persistent (opened via mysql_pconnect) you could lower these numbers to something reasonable like 600 (10 min) or even 60 (1 min). Or, if your app works just fine, you can leave the default. This is up to you.
You must set these as follows in my.cnf (takes effect after mysql restart):
[mysqld]
interactive_timeout=180
wait_timeout=180
If you do not want to restart mysql, then run these two commands:
SET GLOBAL interactive_timeout = 180;
SET GLOBAL wait_timeout = 180;
This will not close the connections already open. This will cause new connections to close in 180 sec.
wait_timeout=180
? – Patrick Mar 3 ‘11 at 22:28