binlog_format
Whether the binary log stores statements, row changes, or a mix.
- Par défaut
ROW- Range
- ROW, STATEMENT, MIXED
- Restart needed
- Non
- Default checked on
- MySQL 8.4 LTS
Ce que cela fait
ROW writes the rows each statement changed, STATEMENT writes the SQL text, and MIXED switches to row logging when a statement is not safe to log as text. Row-based is the default, and 8.4 deprecates the variable itself: the manual says only row-based logging should be used for new replication setups.
Valeur par défaut
ROW. ROW since MySQL 5.7.7 and still the value in MySQL 8.4, where the variable is deprecated and non-ROW values are subject to removal.
Check the current value
SHOW GLOBAL VARIABLES LIKE 'binlog_format'; SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME FROM performance_schema.variables_info WHERE VARIABLE_NAME = 'binlog_format';
Change it
SET SESSION binlog_format = 'ROW'; -- this connection SET GLOBAL binlog_format = 'ROW'; -- new connections, until restart SET PERSIST binlog_format = 'ROW'; -- new connections, and after restarts
No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When to change it
Almost never in 8.4. Servers upgraded from old versions that still run STATEMENT should move to ROW, one replica at a time, because the alternatives are deprecated.
What can go wrong
Statement-based logging replays statements, so their effects can differ on the replica: an UPDATE tied to LIMIT without ORDER BY is the classic unsafe case. READ COMMITTED isolation refuses statement-based logging, and row filters and GTID-oriented tooling assume ROW.
Questions about binlog_format
What is the default value of binlog_format in MySQL?
ROW. ROW since MySQL 5.7.7 and still the value in MySQL 8.4, where the variable is deprecated and non-ROW values are subject to removal.
Does changing binlog_format require a restart?
No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When should I change binlog_format?
Almost never in 8.4. Servers upgraded from old versions that still run STATEMENT should move to ROW, one replica at a time, because the alternatives are deprecated.
Back to all MySQL settings, or check the MySQL manual for every option.
Check binlog_format 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.
Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence