// mysql · wal, redo & durability

sync_binlog

How often the binary log is synced to disk.

Par défaut
1
Range
0 to 4294967295
Restart needed
Non
Default checked on
MySQL 8.4 LTS

Ce que cela fait

1 syncs at every commit group, so a crash cannot lose transactions that were reported committed. 0 leaves flushing to the OS. N syncs every N commit groups.

Valeur par défaut

1. 1 since MySQL 5.7.7 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'sync_binlog';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'sync_binlog';

Change it

SET GLOBAL sync_binlog = 0;    -- until the next restart
SET PERSIST sync_binlog = 0;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

Keep 1 with innodb_flush_log_at_trx_commit=1 on a primary. Relax it only on replicas or throwaway environments.

What can go wrong

Values other than 1 can lose binlog events on a crash, breaking replicas or point-in-time recovery.

Questions about sync_binlog

What is the default value of sync_binlog in MySQL?

1. 1 since MySQL 5.7.7 (MySQL 8.4).

Does changing sync_binlog require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change sync_binlog?

Keep 1 with innodb_flush_log_at_trx_commit=1 on a primary. Relax it only on replicas or throwaway environments.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check sync_binlog 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.