当我运行像“Con%”这样的show status时,它会显示连接的数量,这是9972,并且不断增长。这是活动连接数还是总连接数?
当前回答
根据文档,它指的是历史上的总数:
连接 尝试连接MySQL服务器的次数(成功或失败)。
您可以通过Threads_connected状态变量查看活动连接的数量:
Threads_connected 当前打开的连接数。
mysql> show status where `variable_name` = 'Threads_connected';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 4 |
+-------------------+-------+
1 row in set (0.00 sec)
... 或者通过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)
其他回答
这是到目前为止到服务器的连接总数。 要查找当前连接状态,可以使用
Mysqladmin -u -p extended-status | grep -wi 'threads_connected\|threads_running' | awk '{打印$2,$4}'
这将告诉你:
Threads_connected 12
Threads_running 1
Threads_connected: Number of connections
Threads_running: connections currently running some sql
根据doc http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#statvar_Connections
连接
尝试连接MySQL服务器的次数(成功或失败)。
它应该是当前活动连接的数量。运行processlist命令确认。
参考网址:http://www.devdaily.com/blog/post/mysql/how-show-open-database-connections-mysql
编辑:打开的DB连接数请看这里,实际的线程(连接)数描述在这里!
要查看更完整的列表,您可以运行:
show session status;
or
show global status;
请参阅此链接以更好地理解用法。
如果你想知道数据库的详细信息,你可以运行:
status;
根据文档,它指的是历史上的总数:
连接 尝试连接MySQL服务器的次数(成功或失败)。
您可以通过Threads_connected状态变量查看活动连接的数量:
Threads_connected 当前打开的连接数。
mysql> show status where `variable_name` = 'Threads_connected';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 4 |
+-------------------+-------+
1 row in set (0.00 sec)
... 或者通过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)