MySQL logging

Updated: 14 October 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;

Check the value of log_output

SELECT @@global.log_output;

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