1642
MySQLWARNINGNotableReplicationHIGH confidence
Statement contains both safe and unsafe operations for statement-based replication
Production Risk
Medium — mixed-safety statements can cause replica divergence.
What this means
A single statement mixes operations that are safe and unsafe for statement-based replication, requiring the entire statement to be logged in an unsafe way.
Why it happens
- 1The statement combines deterministic column operations with non-deterministic functions or UDFs.
How to reproduce
trigger — this will error
trigger — this will error
UPDATE t SET col1 = 1, col2 = UUID() WHERE id = 1;
expected output
Warning 1642: Unsafe statement written to the binary log using statement format.
Fix
Use ROW binlog format
Use ROW binlog format
SET SESSION binlog_format = 'ROW';
Why this works
ROW format logs actual row changes, avoiding non-determinism concerns.
Sources
Official documentation ↗
MySQL 8.0 — 1642 ER_BINLOG_UNSAFE_MIXED_STATEMENT
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev