Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14318 reviews 1707 hosting providers

Questions & Answers

Sleeping MySQL connections

Dec 29, 2012 by Susan3
I usually encounter sleeping connections in MySQL, these are mainly connections that are no longer being used but haven’t been closed.
How do I prevent this, or decrease the amount of times these connections stay open for?
Any help would be appreciated.

1 Answer

0 votes
Dec 29, 2012 by SmartHost
You can enable  MySQL to decrease the how long a sleeping connection can remain open
1.Log into your server and make sure your MySQL instance is running.
2.Locate MySQL configuration file. On a Linux OS you would normally find it at "/etc/my.cnf".
3.Open your MySQL configuration file with any text editor, and add the following lines under "[mysqld]"
# Reduced wait_timeout to stop idle connections.
4.You can change the amount of time measured in seconds.
5.When you are done, save the file and then restart MySQL.