MySQL Debug: How to log all queries of an event

December 6, 2016

updated 12-14-2016

MySQL – DEBUG

example:
You are running a software package – which hides its queries so far down in so many included and-or overriding class-function (php?) files it is not worth any more effort trying to find the right one(s).

The easiest method to find all the queries that run during a given event
requires only running 2+ commands:

To start and stop the output, run the commands
SET GLOBAL general_log = 'ON';
and
SET GLOBAL general_log = ‘OFF’;

the output will be found in
/var/lib/mysql/{hostname}.log
(the name of your computer .log)

To save all queries to the mysql database table “general_log”
run the command
SET GLOBAL log_output = ‘TABLE’; (to change it from file to table)
or, to save all queries to a separate file, run the command
SET GLOBAL general_log_file = “mysql-event-log.log”;
to specify your chosen file just for certain events.
It will return to the default file name when you restart mysql.
the default file name is {hostname}.log
(the name of your computer .log)

the log file will be found in
/var/lib/mysql/

Then:
To start and stop the output run the commands
SET GLOBAL general_log = 'ON';
and
SET GLOBAL general_log = ‘OFF’;

Comments are closed.

We try to post all comments within 1 business day