Home >Database >Mysql Tutorial >Is 'show status like 'Con%'' Showing Active or Total MySQL Connections?

Is 'show status like 'Con%'' Showing Active or Total MySQL Connections?

Susan Sarandon
Susan SarandonOriginal
2024-11-13 03:51:02692browse

Is

Determining Active or Total Connections in MySQL using show status

When running 'show status like 'Con%''', it displays a number that represents the connections. But the question arises: is this an active number of connections or a cumulative total?

According to MySQL documentation, it refers to the total number of connections throughout history:

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

To determine the number of active connections, consider using one of the following methods:

Threads_connected Status Variable:

"Threads_connected
The number of currently open connections."

Example:

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

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)

The above is the detailed content of Is 'show status like 'Con%'' Showing Active or Total MySQL Connections?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn