MySQL show status - show open database connections

table of contents

MySQL "show status" FAQ: Can you demonstrate how to use the MySQL show statuscommand to show MySQL variables and status information, such as the number of open MySQL connections?

I don‘t have a whole lot of time today to give this a detailed discussion, but here is a quick look at some MySQL work that I did recently to show MySQL open database connections.

MySQL show status - Open database connections

You can show MySQL open database connections (and other MySQL database parameters) using the MySQL show status command, like this:

mysql> show status like ‘Conn%‘;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 8     |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show status like ‘%onn%‘;
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| Aborted_connects         | 0     |
| Connections              | 8     |
| Max_used_connections     | 4     |
| Ssl_client_connects      | 0     |
| Ssl_connect_renegotiates | 0     |
| Ssl_finished_connects    | 0     |
| Threads_connected        | 4     |
+--------------------------+-------+
7 rows in set (0.00 sec)

  

All those rows and values that are printed out correspond to MySQL variables that you can look at. Notice that I use like ‘Conn%‘in the first example to show variables that look like "Connection", then got a little wiser in my second MySQL show status query.

MySQL show processlist

Here‘s what my MySQL processlist looks like when I had my Java application actively running under Tomcat:

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)

  

And here‘s what it looked like after I shut Tomcat down:

mysql> show processlist;
+----+------+-----------+--------+---------+------+-------+------------------+
| Id | User | Host      | db     | Command | Time | State | Info             |
+----+------+-----------+--------+---------+------+-------+------------------+
|  3 | root | localhost | webapp | Query   |    0 | NULL  | show processlist |
+----+------+-----------+--------+---------+------+-------+------------------+
1 row in set (0.00 sec)

  

As a final note, you can also look at some MySQL variables using the mysqladmin command at the Unix/Linux command line, like this:

$ mysqladmin status

Uptime: 4661  Threads: 1  Questions: 200  Slow queries: 0  Opens: 16  Flush
tables: 1  Open tables: 6  Queries per second avg: 0.043

  

MySQL show status - Summary

Finally, here are two quick links to MySQL status pages:

I hope this brief look at the MySQL SHOW STATUS command has been helpful. As you can see, you can show information about a lot of MySQL status information, including the number of MySQL database connections, MySQL processes, and much more.

时间: 2024-12-21 04:45:35

MySQL show status - show open database connections的相关文章

加大数据库连接数(the Number of Database Connections )

本文参考自: Trying to Increase the Number of Database Connections (Doc ID 167674.1) fact: Oracle Server - Enterprise Edition 8 fact: Solaris Operating System (SPARC) symptom: Trying to Increase the Number of Database Connections symptom: ORA-07252 spcre:

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2822) at com.mysql.jdbc.MysqlIO.checkErrorPa

12. mysql show status

状态名 作用域 详细解释 Aborted_clients Global 由于客户端没有正确关闭连接导致客户端终止而中断的连接数 Aborted_connects Global 试图连接到MySQL服务器而失败的连接数 Binlog_cache_disk_use Global 使用临时二进制日志缓存但超过binlog_cache_size值并使用临时文件来保存事务中的语句 的事务数量 Binlog_cache_use Global 使用临时二进制日志缓存的事务数量 Bytes_received B

Mysql show Status参数详解

状态名 作用域 详细解释 Aborted_clients Global 由于客户端没有正确关闭连接导致客户端终止而中断的连接数 Aborted_connects Global 试图连接到MySQL服务器而失败的连接数 Binlog_cache_disk_use Global 使用临时二进制日志缓存但超过binlog_cache_size值并使用临时文件来保存事务中的语句 的事务数量 Binlog_cache_use Global 使用临时二进制日志缓存的事务数量 Bytes_received B

mysql Ignoring query to other database

mysql 碰到了Ignoring query to other database问题: [email protected] ~]# mysql -root -p --socket=/tmp/mysql.sock Enter password:  Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.6.22-log Source dist

MySQL show status命令参数

Aborted_clients         由于客户没有正确关闭连接已经死掉,已经放弃的连接数量. Aborted_connects 尝试已经失败的MySQL服务器的连接的次数. Binlog_cache_disk_use 当事务日志比binlog_cache_size大时,他会创建临时文件,该状态表示有多少个事务使用了临时文件 Binlog_cache_use        表示有多少个事物使用了binlog_cache_size来缓存未提交的事物日志 Bytes_received 从客户

Go连接MySql数据库Error 1040: Too many connections错误解决

原文:https://my.oschina.net/waknow/blog/205654 摘要: 使用Go链接数据库时,由于连接释放不当会在一段时间以后产生too many connections的错误.因此需要适当的选择函数和及时的释放数据库连接. 这几天用Go写了个简陋的服务器,连接Mysql数据库,提供api给其他程序调用来实现增删改产等服务.Go的版本是1.2,使用的驱动是go-sql-driver/mysql.但是在有一定量的查询结果以后,会出先too many connection的

MySql: show databases/tables use database desc table

1. show databases mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+4 rows in set (0.00 sec) 2. use database_name mysql> use testDatabase

mysql show status查看信息命令

mysql性能命令: 列出所有用户的当前连接: > show processlist;  (只显示前100行) > show full processlist; (显示所有连接) 查看所有mysql信息: > show status; 查看正在使用延迟插入处理器线程的数量: > show status like '%Delayed_insert_threads%'; 同时使用的连接的最大数量: > show status like '%max_used_connections