How do I track query history

MySQL offers several ways to track query history, which can be useful for debugging and performance monitoring. One method involves enabling the general query log, which logs all queries received by the database server.

To enable the general query log, you can set it in the MySQL configuration file (my.cnf) or execute it dynamically using SQL commands. Here's an example:

-- Enable the general query log SET GLOBAL general_log = 'ON'; -- Check the log file location SHOW VARIABLES LIKE 'general_log_file'; -- Disable the general query log SET GLOBAL general_log = 'OFF';

MySQL query history track queries general query log database performance monitoring MySQL debugging