MySql Proccesslist filled with “Sleep” Entries leading to “Too many Connections”?

后端 未结 6 1418
礼貌的吻别
礼貌的吻别 2020-12-12 12:41

I\'d like to ask your help on a longstanding issue with php/mysql connections.

Every time I execute a \"SHOW PROCESSLIST\" command it shows me about 400 idle (Status

6条回答
  •  [愿得一人]
    2020-12-12 13:16

    Before increasing the max_connections variable, you have to check how many non-interactive connection you have by running show processlist command.

    If you have many sleep connection, you have to decrease the value of the "wait_timeout" variable to close non-interactive connection after waiting some times.

    • To show the wait_timeout value:

    SHOW SESSION VARIABLES LIKE 'wait_timeout';

    +---------------+-------+

    | Variable_name | Value |

    +---------------+-------+

    | wait_timeout | 28800 |

    +---------------+-------+

    the value is in second, it means that non-interactive connection still up to 8 hours.

    • To change the value of "wait_timeout" variable:

    SET session wait_timeout=600; Query OK, 0 rows affected (0.00 sec)

    After 10 minutes if the sleep connection still sleeping the mysql or MariaDB drop that connection.

提交回复
热议问题