MySQL數據庫使用情況查詢,慢SQL日誌記錄與配置。(常用命令)

show global status like 'Com_select'; -- 執行select操作的次數
show global status like 'Com_insert';
show global status like 'Com_update';
show global status like 'Com_delete';

show global status like 'Innodb_rows_read'; -- select 查詢返回的行數
show global status like 'Innodb_rows_inserted'; 
show global status like 'Innodb_rows_updated';
show global status like 'Innodb_rows_deleted';

show global status like 'Connections'; -- 試圖連接MySQL服務器的次數
show global status like 'Uptime';	-- 服務器工作時間
show global status like 'Slow_queries'; -- 慢查詢的次數


show variables like '%slow%';	-- 查看慢查詢日誌的相關信息
show variables like 'long_query_time'; -- 指定記錄慢查詢日誌SQL執行時間得伐值(單位:秒,默認10秒)
show variables like 'slow_query_log';	-- 慢查詢日誌的開關
show variables like 'slow_query_log_file'; -- 指定慢查詢日誌得存儲路徑及文件(默認和數據文件放一起)
show variables like 'log_queries_not_using_indexes'; -- 是否記錄未使用***索引***的SQL
show variables like 'log_output'; --  日誌存放的地方【TABLE】【FILE】【FILE,TABLE】(文件 和/或 表)
-- set global slow_query_log=on; -- 開啓慢查詢日誌
-- set global log_output = 'TABLE'; -- 設置日誌輸出方式爲表。
-- select * from mysql.slow_log; -- 慢查詢日誌所存放的表。

-- show processlist
select * from information_schema.processlist ; -- 查詢當前MySQL在進行的線程
 


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章