MySQL显示状态-活动连接还是总连接?

时间:2022-10-02 21:12:17

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?

当我运行“Con%”之类的show状态时,它会显示连接的数量,这是9972,并且不断增加。这是一个活动的连接数或连接总数吗?

7 个解决方案

#1


257  

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

据文献记载,这意味着历史上的总数:

Connections

连接

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

尝试连接到MySQL服务器的次数(成功与否)。

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

您可以通过Threads_connected status变量查看活动连接的数量:

Threads_connected

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:

…或通过show processlist命令:

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)

#2


106  

SHOW STATUS WHERE `variable_name` = 'Threads_connected';

This will show you all the open connections.

这将显示所有打开的连接。

#3


10  

This is the total number of connections to the server till now. To find current conection status you can use

这是到服务器的连接总数。要查找当前的conection状态,可以使用

mysqladmin -u -p extended-status | grep -wi 'threads_connected\|threads_running' | awk '{ print $2,$4}'

mysqladmin -u -p扩展状态| grep -wi 'threads_connected\|threads_running' | awk '{打印$2,$4}

This will show you:

这将告诉你:

Threads_connected 12

Threads_running 1  

Threads_connected: Number of connections

Threads_running: connections currently running some sql

#4


7  

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;

#5


5  

You can also do

你也可以做

SHOW STATUS WHERE `variable_name` = 'Max_used_connections';

#6


2  

It should be the current number of active connections. Run the command processlist to make sure.

它应该是当前活动连接的数量。运行命令processlist以确保。

URL for reference: http://www.devdaily.com/blog/post/mysql/how-show-open-database-connections-mysql

参考网址: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!

编辑:打开的DB连接数请在这里查看,实际的线程数(连接数)在这里描述!

#7


1  

As per doc http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#statvar_Connections

根据医生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.

尝试连接到MySQL服务器的次数(成功与否)。

#1


257  

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

据文献记载,这意味着历史上的总数:

Connections

连接

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

尝试连接到MySQL服务器的次数(成功与否)。

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

您可以通过Threads_connected status变量查看活动连接的数量:

Threads_connected

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:

…或通过show processlist命令:

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)

#2


106  

SHOW STATUS WHERE `variable_name` = 'Threads_connected';

This will show you all the open connections.

这将显示所有打开的连接。

#3


10  

This is the total number of connections to the server till now. To find current conection status you can use

这是到服务器的连接总数。要查找当前的conection状态,可以使用

mysqladmin -u -p extended-status | grep -wi 'threads_connected\|threads_running' | awk '{ print $2,$4}'

mysqladmin -u -p扩展状态| grep -wi 'threads_connected\|threads_running' | awk '{打印$2,$4}

This will show you:

这将告诉你:

Threads_connected 12

Threads_running 1  

Threads_connected: Number of connections

Threads_running: connections currently running some sql

#4


7  

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;

#5


5  

You can also do

你也可以做

SHOW STATUS WHERE `variable_name` = 'Max_used_connections';

#6


2  

It should be the current number of active connections. Run the command processlist to make sure.

它应该是当前活动连接的数量。运行命令processlist以确保。

URL for reference: http://www.devdaily.com/blog/post/mysql/how-show-open-database-connections-mysql

参考网址: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!

编辑:打开的DB连接数请在这里查看,实际的线程数(连接数)在这里描述!

#7


1  

As per doc http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#statvar_Connections

根据医生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.

尝试连接到MySQL服务器的次数(成功与否)。