首先申明:不要在生产环境开启全局查询日志功能;
查询是否开启及路径:
show VARIABLES like '%general_log%';
查询输出格式:
show VARIABLES like '%log_output%';
永久开启:
vim /mysqld/3308/etc/my.cnf
[mysqld]中加入:
general_log=1
general_log_file=/mysqld/3308/var/log/logfile
log_output=FILE|TABLE
临时开启:
set global general_log=1;
set global log_output='TABLE';
开启后,编写的sql将记录在mysql.general_log表中:
select * from mysql.general_log order by event_time desc;