(转)mysql查看正在执行的sql语句

系统管理员 2021-11-01 20:56 528阅读 0赞

有2个方法:

1、使用processlist,但是有个弊端,就是只能查看正在执行的sql语句,对应历史记录,查看不到。好处是不用设置,不会保存。

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

2、开启日志模式

  1. -- 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; 参考资料: https://www.cnblogs.com/bigben0123/p/8920658.html

转载于:https://www.cnblogs.com/Cong0ks/p/11088603.html

发表评论

表情:
评论列表 (有 0 条评论,528人围观)

还没有评论,来说两句吧...

相关阅读