Mysql - How to fix mysql slow connection, Mysql Sleep Connection

How to fix mysql slow connection

How to fix mysql slow connection?

Most of would have faced MySQL slow connection issue, it might be because of improper configuration or bad queries we use. The best way of coding will be to make a check and close MySQL connection properly.

 MySQL: show processlist;
Where, you might find too many sleep connections.

To set MySQL variables during run time
 mysql>SET GLOBAL interactive_timeout = 180;
 mysql>SET GLOBAL wait_timeout = 180;

The same can be configured in MySQL configuration file too
 # vi /etc/my.cnf file

 interactive_timeout = 180;
 wait_timeout = 180;

This will not close the connections already open but, it will cause the new connections to close in 180 sec

To fix MySQL slow connection problem, you have to set the variable as below and restart your MySQL connection
 MySQL: interactive_timeout=180;
 MySQL: set wait_timeout=180;

The topic on Mysql - How to fix mysql slow connection is posted by - Leon

Hope you have enjoyed, Mysql - How to fix mysql slow connectionThanks for your time

Tech Bluff