1.PROCESSLIST
1、使用processlist,但是有個弊端,就是只能查看正在執行的sql語句,對應歷史記錄,查看不到。好處是不用設置,不會保存。
-- use information_schema; -- show processlist; 或者: -- select * from information_schema.`PROCESSLIST` where info is not null;
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;