Web Development

Sleep Process Thread in MySQL

While working with the MySQL Administrator, You can see the list of all connections.

Have you checked the different status of the each connections?

You might get some connections which the status sleep.
MySQL Sleep Thread

Reason for This Connection Status

The reason for getting this type of connection is the MySQL Persistent Connection. So whenever you open the database connection in persistent mode, it will remain open untill some defined time limit.

At this state that database connection will display as status in sleep.

Within this time limit if another user tries to open the connection with same credentials, it will use that connection in sleep mode and connection will become active again.

Default time for leave this connection open is 28,800 seconds. This time can be defined in the configuration file of the mysql as below.

[cc lang=”apache”]
wait_timeout=15
connect_timeout=10
interactive_timeout=100
[/cc]

Remove Sleep Process Thread

To remove any thread in sleep mode, you will need a process ID for thread. You can get this process ID using [code]show processlists;[/code] query.

After getting process ID you can use kill command to kill the database connection.

[cc lang=”apache”]
kill processid
[/cc]

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *