How do I disable or enable MySQL logs

In MySQL, you can control logging behavior through the configuration settings in the MySQL configuration file (usually my.cnf or my.ini). To disable or enable logs, follow the steps below:

Disabling MySQL Logs

To disable logging, you need to comment out or remove the log directives in the MySQL configuration file. The common log types include general log, slow query log, and binary log.

Example to Disable General Log

[mysqld] # general_log = 1

Example to Disable Slow Query Log

[mysqld] # slow_query_log = 1

Example to Disable Binary Log

[mysqld] # log_bin = mysql-bin

Enabling MySQL Logs

To enable logging, ensure that the related log directives in the MySQL configuration file are not commented out. You can set them to 1 to enable logging.

Example to Enable General Log

[mysqld] general_log = 1

Example to Enable Slow Query Log

[mysqld] slow_query_log = 1

Example to Enable Binary Log

[mysqld] log_bin = mysql-bin

After making changes to the configuration file, always restart the MySQL server for the changes to take effect.


mysql logging disable mysql log enable mysql log my.cnf settings