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?
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)
variable_name
= 'Threads_connected';" -bash: variable_name: command not found ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Threads_connected'' at line 1 –
Chosen SHOW STATUS WHERE `variable_name` = 'Threads_connected';
This will show you all the open connections.
variable_name
= 'Threads_connected';" -bash: variable_name: command not found ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Threads_connected'' at line 1 –
Chosen You can also do
SHOW STATUS WHERE `variable_name` = 'Max_used_connections';
max_used_connections
is also useful –
Bourbon 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
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;
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.
SHOW VARIABLES LIKE "max_used_connections";
returned Empty set (0.00 sec)
but SHOW STATUS WHERE variable_name
= 'Max_used_connections'; with "`" around "variable_name" worked –
Subconscious SHOW STATUS WHERE variable_name = "max_used_connections";
–
Tlemcen As per doc http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#statvar_Connections
Connections
The number of connection attempts (successful or not) to the MySQL server.
A GUI solutions of MySQL queries:
If someone wants to show all active connection without any MySQL code, then you can use Session Manager in dbForge Studio:
Simply, open Database > Session Manager in the upper menu, and you'll see all active connections:
It will do the same thing that is done by these MySQL commands:
show full processlist;
SELECT * FROM information_schema.PROCESSLIST p;
SELECT * FROM performance_schema.threads t;
It should be the current number of active connections. Run the command processlist
to make sure.
URL for reference: http://www.devdaily.com/blog/post/mysql/how-show-open-database-connections-mysql
EDIT: Number of DB connections opened Please take a look here, the actual number of threads (connections) are described here!
show status like '%onn%';
is a very useful query. –
Dyun © 2022 - 2024 — McMap. All rights reserved.