How to disable mysql binary log with log_bin variable?
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 explicitly 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…
In MySQL 8, it is the option disable_log_bin which has to be provided without any parameter in the my.cnf file in the [mysqld] section:
[mysqld]
disable_log_bin
some-other-option = any-value
From the manual entry Binary Logging Options and Variables:
To disable mysql binary log, 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.
To retain only a specific minimal amount of data, you can also use binlog_expire_logs_seconds from MySQL 8: Sets the binary log expiration period in seconds. After their expiration period ends, binary log files can be automatically removed. Possible removals happen at startup and when the binary log is flushed.