使用processlist,可是有個弊端,就是隻能查看正在執行的sql語句,對應歷史記錄,查看不到。好處是不用設置,不會保存。html
use information_schema;mysql
show processlist;sql
或者:日誌
-- select * from information_schema.PROCESSLIST
where info is not null;code
-- SET GLOBAL log_output = 'TABLE';SET GLOBAL general_log = 'ON'; //日誌開啓orm
-- SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'OFF'; //日誌關閉htm
SELECT * from mysql.general_log ORDER BY event_time DESC;blog
-- truncate table mysql.general_log;ssl
在查詢sql語句以後,在對應的 C:\Program Files\MySQL\MySQL Server 5.7\data 文件夾下面有對應的log記錄get
ps:在查詢到所須要的記錄以後,應儘快關閉日誌模式,佔用磁盤空間比較大