Software >> Services >> RDBMS >> MYSQL >>  How to enable TRACING of SQL query to a log file

Method 1

1.  login as root

mysql -uroot -p

2.  use mysql database;

mysql> use mysql

3.  check current setting of the varilable general_log

mysql> show variables like 'general_log%';

note value of

      general_log :
      general_log_file :

if general_log is OFF, set it to ON by

4.  set logging to ON and specify the path

mysql> SET GLOBAL general_log='ON';

mysql> SET GLOBAL general_log_file='somepath';

 Method 2

edit /etc/my.cnf

add following line to the mysqld section

log=path-to-query-log

then restart mysql

# /etc/init.d/mysql stop
# /etc/init.d/mysql start