SHOW STATUS提供MySQL服務(wù)的狀態(tài)信息,執(zhí)行這個語句只需要連接到MySQL數(shù)據(jù)庫的權(quán)限。
這些服務(wù)狀態(tài)信息來源于以下:
① 性能用戶的表。
② 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參數(shù),分別顯示全局或當前連接會話信息,如果不帶參數(shù)則顯示的是當前會話的信息。
每次調(diào)用SHOW STATUS語句會使用一個臨時表,并會增加Created_tmp_tables全局參數(shù)的值。
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)
--常用的統(tǒng)計參數(shù)Com_select 執(zhí)行SELECT操作的次數(shù)
Com_insert 執(zhí)行INSERT操作的次數(shù)
Com_update 執(zhí)行UPDATE操作的次數(shù)
Com_delete 執(zhí)行DELETE操作的次數(shù)
Innodb_rows_read InnoDB存儲引擎SELECT查詢返回的行數(shù)
Innodb_rows_inserted InnoDB存儲引擎執(zhí)行INSERT操作插入的行數(shù)
Innodb_rows_updated InnoDB存儲引擎執(zhí)行UPDATE操作更新的行數(shù)
Innodb_rows_deleted InnoDB存儲引擎執(zhí)行DELETE操作刪除的行數(shù)
Connections 連接數(shù)
Uptime
服務(wù)器工作時間
Slow_queries 慢查詢的次數(shù)
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命令介紹
標題網(wǎng)址:http://sd-ha.com/article0/gcjgio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、企業(yè)網(wǎng)站制作、移動網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、ChatGPT
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源:
創(chuàng)新互聯(lián)