SHOW STATUS提供MySQL服务的状态信息,执行这个语句只需要连接到MySQL数据库的权限。
这些服务状态信息来源于以下:
① 性能用户的表。
② INFORMATION_SCHEMA用户下的GLOBAL_STATUS和SESSION_STATUS表。
MariaDB [test]> desc information_schema.global_status;
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| VARIABLE_NAME | varchar(64) | NO | | | |
| VARIABLE_VALUE | varchar(2048) | NO | | | |
+----------------+---------------+------+-----+---------+-------+
2 rows in set (0.12 sec)
MariaDB [test]> select * from information_schema.global_status where variable_name like 'Com_insert%';
+-------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-------------------+----------------+
| COM_INSERT | 106 |
| COM_INSERT_SELECT | 10 |
+-------------------+----------------+
2 rows in set (0.00 sec)
MariaDB [test]> desc information_schema.session_status;
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| VARIABLE_NAME | varchar(64) | NO | | | |
| VARIABLE_VALUE | varchar(2048) | NO | | | |
+----------------+---------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
MariaDB [test]> select * from information_schema.session_status where variable_name like 'Com_insert%';
+-------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-------------------+----------------+
| COM_INSERT | 19 |
| COM_INSERT_SELECT | 0 |
+-------------------+----------------+
2 rows in set (0.00 sec)
③ mysqladmin的extended-status命令
[root@localhost 20160630]# /maria/bin/mysqladmin -uroot -p extended-status|grep Com|more
Enter password:
| Com_admin_commands | 0 |
| Com_alter_db | 0 |
| Com_alter_db_upgrade | 0 |
| Com_alter_event | 0 |
| Com_alter_function | 0 |
| Com_alter_procedure | 0 |
| Com_alter_server | 0 |
| Com_alter_table | 40 |
| Com_alter_tablespace | 0 |
| Com_analyze | 3 |
| Com_assign_to_keycache | 0 |
| Com_begin | 0 |
| Com_binlog | 0 |
| Com_call_procedure | 3 |
| Com_change_db | 43 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_checksum | 0 |
| Com_commit | 0 |
| Com_compound_sql | 0 |
| Com_create_db | 1 |
| Com_create_event | 0 |
| Com_create_function | 0 |
| Com_create_index | 4 |
| Com_create_procedure | 4 |
SHOW STATUS接受GLOBAL或SESSION参数,分别显示全局或当前连接会话信息,如果不带参数则显示的是当前会话的信息。
每次调用SHOW STATUS语句会使用一个临时表,并会增加Created_tmp_tables全局参数的值。
MariaDB [test]> show global status like 'Created_tmp_tables';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| Created_tmp_tables | 894 |
+--------------------+-------+
1 row in set (0.00 sec)
MariaDB [test]> show global status like 'Created_tmp_tables';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| Created_tmp_tables | 895 |
+--------------------+-------+
1 row in set (0.00 sec)
--常用的统计参数Com_select 执行SELECT操作的次数
Com_insert 执行INSERT操作的次数
Com_update 执行UPDATE操作的次数
Com_delete 执行DELETE操作的次数
Innodb_rows_read InnoDB存储引擎SELECT查询返回的行数
Innodb_rows_inserted InnoDB存储引擎执行INSERT操作插入的行数
Innodb_rows_updated InnoDB存储引擎执行UPDATE操作更新的行数
Innodb_rows_deleted InnoDB存储引擎执行DELETE操作删除的行数
Connections 连接数
Uptime
服务器工作时间
Slow_queries 慢查询的次数
MariaDB [test]> show global status like 'Innodb_rows%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Innodb_rows_deleted | 512 |
| Innodb_rows_inserted | 1662 |
| Innodb_rows_read | 4557 |
| Innodb_rows_updated | 4 |
+----------------------+-------+
4 rows in set (0.00 sec)
MariaDB [test]> show global status like 'Connection%';
+-----------------------------------+-------+
| Variable_name | Value |
+-----------------------------------+-------+
| Connection_errors_accept | 0 |
| Connection_errors_internal | 0 |
| Connection_errors_max_connections | 0 |
| Connection_errors_peer_address | 0 |
| Connection_errors_select | 0 |
| Connection_errors_tcpwrap | 0 |
| Connections | 15 |
+-----------------------------------+-------+
7 rows in set (0.00 sec)
MariaDB [test]> show global status like 'Uptime%';
+---------------------------+---------+
| Variable_name | Value |
+---------------------------+---------+
| Uptime | 1285789 |
| Uptime_since_flush_status | 1285789 |
+---------------------------+---------+
2 rows in set (0.00 sec)
MariaDB [test]> show global status like 'Slow_queries%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries | 0 |
+---------------+-------+
1 row in set (0.00 sec)
网页标题:MySQLSHOWSTATUS命令介绍
标题链接:
http://6mz.cn/article/gcjgio.html