Selecting  query log output destinations

You can log the queries to either FILE or TABLE in MySQL itself by specifying the log_output variable, which can be either FILE or TABLE, or both FILE and TABLE.

If you specify log_output as FILE, the general query log and the slow query log will be written to the files specified by general_log_file and slow_query_log_file, respectively.

If you specify log_output as TABLE, the general query log and the slow query log will be written to the mysql.general_log and mysql.slow_log tables respectively. Log contents are accessible through SQL statements.

For example:

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.02 ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.