Enabling Mysql Logging

From Integrics Wiki
Jump to: navigation, search

On the fly (Mysql 5.1 and above)

On the mysql client command line:

touch /var/log/mysql.log
chown mysql /var/log/mysql.log
mysql -u root enswitch -p

At the mysql console type:

SET GLOBAL general_log_file = '/var/log/mysql.log';
SET GLOBAL general_log = 1;

Make the test call, and then to disable logging type at the mysql console:

SET GLOBAL general_log = 0;

Use "quit" to exit the mysql console.

In my.conf (all Mysql versions)

  • Create the log file and set permissions:
touch /var/log/mysql.log
chown mysql /var/log/mysql.log
  • Edit /etc/mysql/my.conf or /etc/my.conf (whichever exists on your system) and add or uncomment the lines:
general_log_file = /var/log/mysql.log
general_log = 1
  • Save and exit your text editor.
  • Run:
/etc/init.d/mysqld restart
  • After you've obtained the information required remember to comment out the logging lines again and restart MySQL, otherwise the log file will grow extremely large. It does not wrap itself.