Default MySQL config file /etc/mysql/my.cnf installed by some debian package using APT often set log_bin variable, so binlog are enabled:

log_bin = /var/log/mysql/mysql-bin.log

When I want to disable binary logging on such installation, comment out the line in my.cnf works of course, but I wonder if there is a way to disable binary logging by setting explicitely log_bin to OFF, in a debian style, I mean in an included file like /etc/mysql/conf.d/myCustomFile.cnf, so default my.cnf is not changed and can be easily updated by apt, if necessary.

I tried "log_bin = 0", "log_bin = OFF" or "log_bin =" but none works...


This is an old question, but it came up in a search while I was trying to jog my memory about the correct option name and so now that I've figured it out I'm adding the details here.

The key part of the question is:

I mean in an included file like /etc/mysql/conf.d/myCustomFile.cnf

You can do this from an included option file using the option skip-log-bin. E.g. you might create /etc/mysql/conf.d/disable_binary_log.cnf with the following contents:


You can add skip- as a prefix to other options to disable them in this way too.

  • 1
    Great, exactly what I was expecting. That works well on MariaDB 10.0 at least. Thanks a lot. – Nicolas Payart Nov 11 '15 at 16:27

You can see it like this, log_bin should not accept parameters, either you put:


or nothing at all, as it is a boolean parameter.

However, if a value is set, logs are enabled and the value interpreted as the binlog basename.

Log options have a history of not being too intuitive, and changing its format from version to version (I am looking at you, slow log).

  • It doesn't work on MariaDB – MechanTOurS Jul 17 '15 at 13:38
  • Given that I use MariaDB, and I have this exact same line on my config, I am very confident that it works. – jynus May 26 '16 at 8:34

In MySQL 8 it is the option disable_log_bin which has to provided without any parameter in the my.cnf file in the [mysqld] section.

some-other-option = any-value

If you are not replicating, you can disable binlogging by changing your my.ini or my.cnf file. Open your my.ini or /etc/my.cnf (/etc/mysql/my.cnf), enter:

# vi /etc/my.cnf

Find a line that reads "log_bin" and remove or comment it as follows:

#log_bin = /var/log/mysql/mysql-bin.log

You also need to remove or comment following lines:

#expire_logs_days = 10

#max_binlog_size = 100M

Close and save the file. Finally, restart mysql server:

# service mysql restart

  • 1
    I think the OP understands this, which is why he wrote: "I mean in an included file like /etc/mysql/conf.d/myCustomFile.cnf, so default my.cnf is not changed" – Peter V. Mørch Jan 30 '15 at 10:02

From the Manual for MariaDB (https://mariadb.com/kb/en/library/activating-the-binary-log/)

If you don't provide a name (which can, optionally, include an absolute path), the default will be datadir/log-basename-bin, datadir/mysql-bin or datadir/mariadb-bin


Clients with the SUPER privilege can disable and re-enable the binary log for the current session by setting the sql_log_bin variable.

SET sql_log_bin = 0;

SET sql_log_bin = 1;

However, if you say it was enabled by default during installation, you must disable by removing the line from your my.cnf file and then restart mysqld. You can also purge the binary data (https://dev.mysql.com/doc/refman/5.6/en/purge-binary-logs.html)


Finally, as the other poster's answer mentions, in MySQL 8 there is an option to explicitly turn off binary logging from the configuration file using the --skip-log-bin or --disable-log-bin options in the [mysqld] section of the config file.

To disable binary logging, you can specify the --skip-log-bin or --disable-log-bin option at startup. If either of these options is specified and --log-bin is also specified, the option specified later takes precedence. When binary logging is disabled, the log_bin system variable is set to OFF.


As I know after updating a package, the config file should be the old one, so after update you have the same config files. Otherwise you can create a second config file in path $MYSQL_HOME/my.cnf. This one is for server specific options and as I know will overwrite the settings in global /etc/my.cnf

  • 1
    Yes, Debian default policy does not overwrite a config file in /etc. But my question was precisely how to overwrite log_bin setting with a "null value" WITHOUT commenting the line in the /etc/mysql/my.cnf. – Nicolas Payart Aug 1 '14 at 8:58
  • skip-log-bin turns off booleans set elsewhere – santiago arizti Mar 7 '18 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.