1592: ER_BINLOG_UNSAFE_STATEMENT: Unsafe statement written to the binary log
MySQLWhat does it mean?
While using the STATEMENT-based binlog format, a statement with a nondeterministic result (one that could produce a different result on the replica) was executed. MySQL issues a warning when writing it to the binlog because there is a risk of data inconsistency between source and replica.
Why does it happen?
With binlog_format=STATEMENT: nondeterministic functions such as UUID(), SYSDATE() or USER() (NOW() replicates safely with STATEMENT), UPDATE/DELETE with LIMIT but no ORDER BY, INSERTs mixed with AUTO_INCREMENT, or certain user-defined/system functions. These statements may not produce the same result on every server.
How to fix it
Switch the binlog format to row-based (recommended; ROW has been the default since MySQL 5.7.7): binlog_format=ROW in my.cnf or SET PERSIST binlog_format = ROW; (the binlog_format variable is deprecated since 8.0.34; the change takes effect for new sessions). ROW format replicates nondeterministic statements safely. If you must stay on STATEMENT, replace nondeterministic functions/expressions with constant values and add a deterministic ORDER BY to DML with LIMIT.
More from this engine
- 3819ER_CHECK_CONSTRAINT_VIOLATED: Check constraint is violated
- 1118ER_TOO_BIG_ROWSIZE: Row size too large
- 1170ER_BLOB_KEY_WITHOUT_LENGTH: BLOB/TEXT column used in key specification without a key length
- 3140ER_INVALID_JSON_TEXT: Invalid JSON text
- 1526ER_NO_PARTITION_FOR_GIVEN_VALUE: Table has no partition for value
- 1049Unknown database 'name'
- 1364Field 'name' doesn't have a default value