1. Bicom Systems
  2. Solution home
  3. SERVERware
  4. HOWTOs SERVERware 5

HOWTO :: MySQL General Log

The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.



There are 2 ways to enable / disable the general log. 


    • Using config file ( Requires a MySQL Restart )

    • Using MySQL ( Done through MySQL console. Does not require a restart )



Enabling General Log using config files.


• Edit MySQL configuration file

 nano /opt/pbxware/pw/etc/mysql/my.cnf


 • Define logging file and enable general logging under [mysqld] section :

general_log_file=/var/log/mysql/general.log
general_log='ON'


    • Create logging file

touch /opt/pbxware/pw/var/log/mysql/general.log


    • Edit file ownership and permissions

chown 60:60 /opt/pbxware/pw/var/log/mysql/general.log
chmod 660 /opt/pbxware/pw/var/log/mysql/general.log

     • Restart MySQL




Enabling General Log using MySQL console.



    • Open MySQL ( /opt/pbxware/sh/mysql )


    • Define Logging file and enable general logging by using the following queries.

      

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




NOTE:

For mysql versions lower than 5.1.29 the general log is enabled by setting the value as 1 / 0 instead of ON / OFF. 

Example:

SET GLOBAL general_log = 1;