Trace history of queries executed in MySQL

Trace history of queries executed in MySQL

You need to enable the MySQL Log first to trace the query executions.

You have two options for this, those are given below,

To control this option on table level,

Execute SET GLOBAL log_output = 'TABLE';

Execute SET GLOBAL general_log = 'ON';

Take a look at the table mysql.general_log

Query to fetch data from mysql.general_log,

SELECT * FROM  mysql.general_log  WHERE command_type ='Query' LIMIT total;

To control this option on file level,

SET GLOBAL log_output = "FILE"; the default. 
SET GLOBAL general_log_file = "/path/to/your/logfile.log";

SET GLOBAL general_log = 'ON';

You can do this by editing .cnf file also.


No comments:

Post a Comment

Pages