轉(zhuǎn)MySQL查看數(shù)據(jù)庫性能常用命令
mysql> show global status; 列出MySQL服務(wù)器運行各種狀態(tài)值
mysql> show variables; 查詢MySQL服務(wù)器配置信息語句
一、慢查詢
mysql> show variables like '%slow%';
mysql> show global status like '%slow%';
二、連接數(shù)
mysql> show variables like 'max_connections'; max_connections值過小:
mysql> show global status like ‘Max_used_connections’;
三、Key_buffer_size
mysql> show variables like ‘key_buffer_size’; 以MyISAM為主要存儲引擎服務(wù)器的配置
mysql> show global status like 'key_read%'; key_buffer_size的使用情況
mysql> show global status like 'key_blocks_u%'; key_blocks_*參數(shù)
四、臨時表
mysql> show global status like 'created_tmp%';
mysql> show variables where Variable_name in ('tmp_table_size', 'max_heap_table_size'); MySQL服務(wù)器對臨時表的配置
五、Open Table情況
mysql> show global status like 'open%tables%'; Open_tables表示打開表的數(shù)量,Opened_tables表示打開過的表數(shù)量
mysql> show variables like 'table_cache'; 服務(wù)器table_cache值
六、進程使用情況
mysql> show global status like ‘Thread%’; Threads_created表示創(chuàng)建過的線程數(shù)
mysql> show variables like 'thread_cache_size'; 查詢服務(wù)器thread_cache_size配置
七、查詢緩存(query cache)
mysql> show global status like 'qcache%';
mysql> show variables like 'query_cache%'; 服務(wù)器關(guān)于query_cache的配置
八、排序使用情況
mysql> show global status like 'sort%';
九、文件打開數(shù)(open_files)
mysql> show global status like 'open_files';
十、表鎖情況
mysql> show global status like 'table_locks%';
十一、表掃描情況
mysql> show global status like 'handler_read%';
mysql> show global status like 'com_select'; 調(diào)出服務(wù)器完成的查詢請求次數(shù)