把SQL记录在表中,请不要再生产环境使用。
mysql> SET GLOBAL log_output = 'TABLE';
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.16 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from mysql.general_log order by event_time desc limit 10;
清理记录的SQL,请使用truncate,如果使用delete你将不能成功。
mysql> delete from mysql.general_log;
ERROR 1556 (HY000): You can't use locks with log tables.
mysql> truncate table mysql.general_log;
Query OK, 0 rows affected (0.05 sec)
也可以把日志输出到文件
SET GLOBAL log_output = "FILE";
SET GLOBAL general_log_file = "/path/to/your/logfile.log"
