NO_WRITE_TO_BINLOG (synonym LOCAL) is a statement-level modifier available in MySQL and MariaDB. Placing it immediately after the leading keyword of certain administrative or maintenance statements tells the server not to record that statement in the binary log. Because replication relies on the binary log, replicas do not execute statements marked with NO_WRITE_TO_BINLOG. The modifier is often used for operations that must run only on the primary server, such as quick statistics gathering or table maintenance, and for commands that would otherwise bloat the binary log without adding value to replicas.Supported statements include (but are not limited to): FLUSH, OPTIMIZE TABLE, ANALYZE TABLE, REPAIR TABLE, CHECK TABLE, RESET MASTER, RESET SLAVE, and RESET REPLICA. DML statements like INSERT or UPDATE do not accept the modifier; to suppress logging for those you must set the session variable sql_log_bin to 0.NO_WRITE_TO_BINLOG affects only binary logging. It does not disable the general query log, slow query log, or error log, and it has no impact on the storage engine’s transactional behavior. The user executing the statement still needs the same privileges as when the modifier is not present.
LOCAL keyword, sql_log_bin system variable, binary logging, replication, FLUSH, OPTIMIZE TABLE, ANALYZE TABLE
MySQL 4.0
Both keywords are synonyms. Using either one prevents the statement from being written to the binary log.
No. Standard DML commands do not accept the modifier. To suppress binary logging for DML, set the session variable `sql_log_bin` to 0.
No additional privileges are needed beyond those required for the base statement itself.
Query `SHOW BINLOG EVENTS` or check the binary log on a replica. The modified statement will not appear.