mysql view the sql statement being executed

There are 2 methods:

1. Use processlist, but there is a disadvantage, that is, you can only view the sql statement that is being executed, and the corresponding history record cannot be viewed. The advantage is that it does not need to be set and will not be saved.

-- use information_schema;
-- show processlist;
或者:
-- select * from information_schema.`PROCESSLIST` where info is not null;

2. Enable log mode

-- 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;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324693802&siteId=291194637