mysql查看執行sql語句的記錄日誌

一、正在執行的sql語句

使用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

三、清空表(delete對於這個表,不容許使用,只能用truncate)

-- truncate table mysql.general_log;ssl

在查詢sql語句以後,在對應的 C:\Program Files\MySQL\MySQL Server 5.7\data 文件夾下面有對應的log記錄get

ps:在查詢到所須要的記錄以後,應儘快關閉日誌模式,佔用磁盤空間比較大

原文:http://www.javashuo.com/article/p-cvnnnemf-dg.html

相關文章
相關標籤/搜索