码迷,mamicode.com
首页 > 数据库 > 详细

两种方式:mysql查看正在执行的sql语句

时间:2018-09-03 10:04:32      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:view   int   art   就是   off   Fix   count   log   box   

mysql查看正在执行的sql语句

有2个方法:

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

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

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;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

两种方式:mysql查看正在执行的sql语句

标签:view   int   art   就是   off   Fix   count   log   box   

原文地址:https://www.cnblogs.com/duanweishi/p/9576469.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!