how to kill close null or sleep mysql process

How to kill or close the null and sleep Mysql process

Normally mysql processes are closed automatically once processed its request.

On worst case scenarios, Mysql process will not be  closing the connections and keeping too many null or sleep process.
Which will cause much load and problems for the mysql and may eats up the RAM on the server.

Sleep process are connections waiting for new query. This will happen if the mysql database connection is not closed properly. also if you are using mysql_pconnect() command in your php script this will happen.

so, you should close the DB connection after the query completed by adding mysql_close() function in the end of script where you have opened MySQL connection.
By this way, mysql sleep process will be closed.

This can also be easily resolved by adding session timeouts on my.cnf file on your server.

nano /etc/my.cnf

add the below lines on it, Once done restart the mysql server.

wait_timeout = 120

The number here is taken in seconds. so based on that you can change the limits you want.
On out case, after 120 seconds, the sleep process will be closed and this will increase your server performance.


This site uses Akismet to reduce spam. Learn how your comment data is processed.