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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7432241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:05:01  来源:igfitidea点击:

MySQL show status - active or total connections?

mysqlconnection

提问by Michael

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?

当我运行时,show status like 'Con%'它会显示连接数,即 9972 并且还在不断增长。这是活动的连接数还是总连接数?

回答by kiiwii

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

根据docs,这意味着历史上的总数:

Connections

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

Connections

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

You can see the number of activeconnections either through the Threads_connectedstatus variable:

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

Threads_connected

The number of currently open connections.

Threads_connected

当前打开的连接数。

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 processlistcommand:

...或通过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)

回答by mistahenry

SHOW STATUS WHERE `variable_name` = 'Threads_connected';

This will show you all the open connections.

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

回答by Pranab Sharma

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}'

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

回答by Mugur 'Bud' Chirica

To see a more complete list you can run:

要查看更完整的列表,您可以运行:

show session status;

or

或者

show global status;

See this linkto better understand the usage.

请参阅此链接以更好地了解用法。

If you want to know details about the database you can run:

如果您想了解有关数据库的详细信息,可以运行:

status;

回答by saurabh

You can also do

你也可以这样做

SHOW STATUS WHERE `variable_name` = 'Max_used_connections';

回答by Mujtaba

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.

希望能帮助到你。

回答by Harsh Gupta

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 服务器的尝试次数(成功与否)。

回答by ChrisH

It should be the current number of active connections. Run the command processlistto 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 openedPlease take a look here, the actual number of threads (connections) are described here!

编辑:打开的数据库连接数请看这里,这里描述了实际的线程(连接)数!