> SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'ON'; //日志开启(日志输出到表:mysql.general_log)
> SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'OFF'; //日志关闭> show variables like '%log_output%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | FILE |
+---------------+-------+> show variables like '%general_log%';
+------------------+------------------------------+
| Variable_name | Value |
+------------------+------------------------------+
| general_log | ON |
| general_log_file | /var/log/mariadb/mariadb.log |
+------------------+------------------------------+ * 查看日志文件中的执行记录:
#tail -f /var/log/mariadb/mariadb.log
......
347189 Query INSERT INTO `table_copy1` (`id`, `col02_str`, `col03_str`, `col04_int`, `col05_integer`, `col06_bigint`)
VALUES ( 1, 'aaaa', 'bbbbb', 20, 30, 655360),
( 2, 'xxxx', 'yyyy', 21, 333, 65536000),
( 3, 'asasdf', 'sdkfjdkf', 55, 900, 2222),
( 4, 'test', 'testaaa', 11, 22, 33),
( 5, 'test05', 'testssssss', 222, 222, 222),
( 6, 'test06', 'aaaa', 111, 111, 222),
( 7, 'aaaa', 'bbbb', 22, 22, 22),
( 8, '你好', 'hello', 25, 25, 25),
( 9, 'aaa', 'aaa', 11, 11, 11),
( 10, '', 'bbbbddddrrrrssss4444', null, null, null),
347189 Query commit
......* 表查询执行记录:
> SELECT * from mysql.general_log ORDER BY event_time DESC;* 日志查询执行记录
> SELECT * from mysql.general_log ORDER BY event_time DESC;* 清空表
> truncate table mysql.general_log; //该表仅支持truncate不支持delete