Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable binary logging in MySQL/8 for Windows

I want to disable binary logging in order to diagnose some uninteresting issue. I've never used replication anyway—it's enabled only because it's the default in MySQL/8. Google shows like 20 different ways to do it and none seem to work in my set up.

The official manual says:

To disable binary logging, you can specify the --skip-log-bin or --disable-log-bin option at startup.

It runs as Windows service, installed with the official MySQL Installer application, so I used regedit (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MySQL80\ImagePath), but either flags, in any location, either standalone or with =1, prevent the service from starting yet log file doesn't include any error message.

I've also read you can have this in defaults file:

[mysqld]
skip-log-bin

Server starts, bug binary logging remains enabled.

Setting an MYSQLD_OPTS environment variable with --skip-log-bin=1 is ignored (perhaps it's exclusive to some Linux distro).

How do you disable binary logging in MySQL/8 on Windows?


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MySQL80\ImagePath

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80

C:\ProgramData\MySQL\MySQL Server 8.0\my.ini:

[client]
port=3306

[mysql]
no-beep

[mysqld]
port=3306
datadir=C:/ProgramData/MySQL/MySQL Server 8.0/Data
default_authentication_plugin=mysql_native_password
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
log-output=FILE
general-log=0
general_log_file="FOO.log"
slow-query-log=1
slow_query_log_file="FOO-slow.log"
long_query_time=10
# One of my failed attempts:
skip-log-bin
like image 887
Álvaro González Avatar asked Oct 26 '25 03:10

Álvaro González


2 Answers

It appears that the issue is related to the order of operations.

If the --skip-log-bin or --disable-log-bin option is specified at startup, binary logging is disabled, with the log_bin system variable set to OFF. If either of these options is specified and --log-bin is also specified, the option specified later takes precedence. [sic]

Configuration Options

By default MySQL sets a configuration value of log-bin="FOO.bin", you would need to ensure that skip-log-bin is declared BELOW or AFTER the log-bin configuration option.

C:\ProgramData\MySQL\MySQL Server 8.0\my.ini

[mysqld]

#...

log-bin="FOO.bin"
skip-log-bin

After saving the configuration file, restart the MySQL service.

SELECT @@GLOBAL.log_bin, @@GLOBAL.version, @@GLOBAL.version_comment, @@GLOBAL.version_compile_os;

Result

+------------------+------------------+------------------------------+-----------------------------+
| @@GLOBAL.log_bin | @@GLOBAL.version | @@GLOBAL.version_comment     | @@GLOBAL.version_compile_os |
+------------------+------------------+------------------------------+-----------------------------+
|                0 | 8.0.21           | MySQL Community Server - GPL | Win64                       |
+------------------+------------------+------------------------------+-----------------------------+
1 row in set (0.00 sec)

Testing with skip-log-bin being declared prior to or above log-bin, even when using log-bin=0 or log-bin=OFF resulted in the log-bin declaration taking precedence - converting the specified log-bin value to a string.
Removing the log-bin declaration and declaring skip-log-bin anywhere, resulted in log_bin as OFF


Environment Variables

The environment variable MYSQLD_OPTS is specific to systemd (Linux) environments. [sic] [sic]

There does not appear to be an equivalent environment variable for Windows. [sic] Which I believe do not apply when running MySQL as a Windows service.

like image 113
Will B. Avatar answered Oct 27 '25 17:10

Will B.


It works for me after I've declared disable_log_bin and commented the log-bin in my.cnf.

like image 34
user223628 Avatar answered Oct 27 '25 15:10

user223628



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!