Article ID: 4336, created on Mar 24, 2008, last review on Aug 25, 2015

  • Applies to:
  • Plesk for Linux/Unix
  • H-Sphere

Symptoms

How to enable MySQL logging?

Resolution

Edit '/etc/my.cnf' (for RedHat-based systems) or '/etc/mysql/my.cnf' (for Debian-based systems) file.

For MySQL versions prior to 5.1

  1. Add 'log' parameter under [mysqld] section:

    log = /path/to/log/file
    
  2. Make sure log file exists and has correct privileges:

    # ls -l /var/log/mysql/mysql.log
    -rw-rw---- 1 mysql root 190 Aug 21 00:29 /var/log/mysql/mysql.log   
    
  3. Restart MySQL service:

    # /etc/init.d/mysqld restart
    

For MySQL version 5.1 and higher

Since version 5.1.29 the log option is deprecated.

  1. Add 'general_log' parameters under [mysqld] section: To enable logging add the following to 'my.cnf':

    general_log = on
    general_log_file=/path/to/query.log
    

    To disable or enable the general query log or change the log file name at runtime, use the global general_log and general_log_file system variables. Set general_log to 0 (or OFF) to disable the log or to 1 (or ON) to enable it.

    e.g.

    SET GLOBAL general_log = 'ON';
    
  2. Make sure log file exists and has correct privileges:

    # ls -l /var/log/mysql/mysql.log
    -rw-rw---- 1 mysql root 190 Aug 21 00:29 /var/log/mysql/mysql.log   
    
  3. Restart MySQL service:

    # /etc/init.d/mysqld restart
    

Search Words

MySQl

logging

MySQL logging

6311ae17c1ee52b36e68aaf4ad066387 f213b9fa8759d57bee5d547445806fe7 29d1e90fd304f01e6420fbe60f66f838 56797cefb1efc9130f7c48a7d1db0f0c a914db3fdc7a53ddcfd1b2db8f5a1b9c

Email subscription for changes to this article
Save as PDF