Pages

Welcome to My Blog

This is to share my IT experience with friends all around the world.
I have been working in Linux Fedora Systems for more than 8 years. Its fun to share knowledge and learn..
As everyone knows when a problem arises in your systems "googling" is the way that many depend on..

All the posts here are my working experiences during my working life.. So you can count on it..

I have added the references where I got help in solving IT issues


Thursday, November 1, 2012

Set Timeout value for a mysql Connection

Due to bad handing of mysql connections (Not properly closed the connections ) there will be several already used open mysql connections waiting to close. By default the connection waiting timeout and the interactive time out values are 8 hours (28800 seconds).
Times set in your mysql server can be observed using following commands;

mysql> show variables like "%timeout%";


It will list down several timeout settings including interactive_timeout and  wait_timeout

If you want to set these values according to your requirement edit your my.cnf (Default location is /etc/my.cnf) and add following setting under mysqld.

[mysqld]
interactive_timeout=3360
wait_timeout=3360


As given above I have set the value to 3360 ( which is 1 hour)

Then restart the service and it will effect the new connections.

Good reference:
http://stackoverflow.com/questions/4284194/terminating-idle-mysql-connections
http://dba.stackexchange.com/questions/1558/how-long-is-too-long-for-mysql-connections-to-sleep

No comments:

Post a Comment