MySQL show status - active or total connections?

前端 未结 8 616
旧时难觅i
旧时难觅i 2020-11-27 09:07

When I run show status like \'Con%\' it shows the number of connections, which is 9972 and constantly growing. Is this an active number of connections or connec

8条回答
  •  無奈伤痛
    2020-11-27 09:43

    According to the docs, it means the total number throughout history:

    Connections

    The number of connection attempts (successful or not) to the MySQL server.

    You can see the number of active connections either through the Threads_connected status variable:

    Threads_connected

    The number of currently open connections.

    mysql> show status where `variable_name` = 'Threads_connected';
    +-------------------+-------+
    | Variable_name     | Value |
    +-------------------+-------+
    | Threads_connected | 4     |
    +-------------------+-------+
    1 row in set (0.00 sec)
    

    ... or through the show processlist command:

    mysql> show processlist;
    +----+------+-----------------+--------+---------+------+-------+------------------+
    | Id | User | Host            | db     | Command | Time | State | Info             |
    +----+------+-----------------+--------+---------+------+-------+------------------+
    |  3 | root | localhost       | webapp | Query   |    0 | NULL  | show processlist | 
    |  5 | root | localhost:61704 | webapp | Sleep   |  208 |       | NULL             | 
    |  6 | root | localhost:61705 | webapp | Sleep   |  208 |       | NULL             | 
    |  7 | root | localhost:61706 | webapp | Sleep   |  208 |       | NULL             | 
    +----+------+-----------------+--------+---------+------+-------+------------------+
    4 rows in set (0.00 sec)
    

提交回复
热议问题