MySQL logging

Updated: 31 March 2024

This is how to enable the log table and query it directly with SQL

SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
SELECT * FROM mysql.general_log ORDER BY event_time DESC;

Enable logging temporarily and write the log entries to a file

SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/mysql-all.log';
SET global general_log = 1;

Leave a comment