mysql查看正在執行的sql語句


有2個方法:

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;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM