兩種方式:mysql查看正在執行的sql語句
阿新 • • 發佈:2018-09-03
read roc output stat 方法 sql語句 for -i 語句
mysql查看正在執行的sql語句
2015年08月21日 17:32:59 閱讀數:15398有2個方法:
1、使用processlist,但是有個弊端,就是只能查看正在執行的sql語句,對應歷史記錄,查看不到。好處是不用設置,不會保存。
-- use information_schema;
-- show processlist;
或者:
-- select * from information_schema.`PROCESSLIST` where info is not null;
- 1
- 2
- 3
- 4
2、開啟日誌模式
-- 1、設置
-- SET GLOBAL log_output = ‘TABLE‘; SET GLOBAL general_log = ‘ON‘;
-- SET GLOBAL log_output = ‘TABLE‘; SET GLOBAL general_log = ‘OFF‘;
-- 2、查詢
SELECT * from mysql.general_log ORDER BY event_time DESC
-- 3、清空表(delete對於這個表,不允許使用,只能用truncate)
-- truncate table mysql.general_log;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
兩種方式:mysql查看正在執行的sql語句