log_bin
Whether the binary log is enabled.
- Standard
ON- Range
- ON, OFF
- Restart needed
- Ja
- Default checked on
- MySQL 8.4 LTS
Was es bewirkt
The binary log feeds replication and point-in-time recovery. The variable shows the state; you control it at startup: --log-bin[=base_name] enables it, --skip-log-bin or --disable-log-bin turns it off.
Standardwert
ON. ON since MySQL 8.0 (it was off in 5.7). Same in 8.4.
Check the current value
SHOW GLOBAL VARIABLES LIKE 'log_bin'; SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME FROM performance_schema.variables_info WHERE VARIABLE_NAME = 'log_bin';
Change it
-- SET PERSIST_ONLY log_bin fails: error 1238, non persistent read only variable. -- Add this line under [mysqld] in my.cnf, then restart mysqld: -- skip-log-bin
Restart required, and the variable cannot be persisted: SET GLOBAL and SET PERSIST_ONLY both fail with error 1238. Set it under [mysqld] in my.cnf or on the mysqld command line.
When to change it
Disable it only on standalone servers with no replicas and no point-in-time recovery needs, such as CI databases.
What can go wrong
Without it there is no replication from this server and no recovery to a point between backups.
Questions about log_bin
What is the default value of log_bin in MySQL?
ON. ON since MySQL 8.0 (it was off in 5.7). Same in 8.4.
Does changing log_bin require a restart?
Yes. Restart required, and the variable cannot be persisted: SET GLOBAL and SET PERSIST_ONLY both fail with error 1238. Set it under [mysqld] in my.cnf or on the mysqld command line.
When should I change log_bin?
Disable it only on standalone servers with no replicas and no point-in-time recovery needs, such as CI databases.
Back to all MySQL settings, or check the MySQL manual for every option.
Check log_bin on your own server
SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.