From:http://dba.stackexchange.com/questions/1558/how-long-is-too-long-for-mysql-connections-to-sleep
20down votefavorite 11 |
I logged onto my server to check the status of the database and noticed on the What duration should the connection time limit be before the connection should be killed? How do I set the time limit in MySQL 5.0.51a-3ubuntu5.4? Note: I am using PHP 5.2.x and symfony framework 1.2.
|
|||
add a comment |
1 Answer
up vote32down voteaccepted |
mysqld will timeout DB Connections based on two(2) server options:
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):
If you do not want to restart mysql, then run these two commands:
This will not close the connections already open. This will cause new connections to close in 180 sec.
|
||||||||||||
|