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 connections made in total?
DanM7
2,1753 gold badges26 silver badges45 bronze badges
asked Sep 15, 2011 at 14:10
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]
answered Nov 10, 2011 at 13:52
kiiwiikiiwii
7,2032 gold badges16 silver badges9 bronze badges
5
SHOW STATUS WHERE `variable_name` = 'Threads_connected';
This will show you all the open connections.
answered Jul 8, 2013 at 22:18
mistahenrymistahenry
8,4543 gold badges26 silver badges38 bronze badges
1
You can also do
SHOW STATUS WHERE `variable_name` = 'Max_used_connections';
SherylHohman
15.1k17 gold badges84 silver badges89 bronze badges
answered Jan 28, 2017 at 9:53
saurabhsaurabh
2,2771 gold badge17 silver badges8 bronze badges
2
This is the total number of connections to the server till now. To find current conection status you can use
mysqladmin -u -p extended-status | grep -wi 'threads_connected\|threads_running' | awk '{ print $2,$4}'
This will show you:
Threads_connected 12
Threads_running 1
Threads_connected: Number of connections
Threads_running: connections currently running some sql
answered Aug 26, 2013 at 11:44
To see a more complete list you can run:
show session status;
or
show global status;
See this link to better understand the usage.
If you want to know details about the database you can run:
status;
answered Sep 25, 2015 at 14:05
In order to check the maximum allowed connections, you can run the following query:
SHOW VARIABLES LIKE "max_connections";
To check the number of active connections, you can run the following query:
SHOW VARIABLES LIKE "max_used_connections";
Hope it helps.
answered Jan 13, 2020 at 10:11
MujtabaMujtaba
1371 silver badge8 bronze badges
3