<p>The statement touches a system variable whose value may differ on replicas, so MySQL flags it as unsafe for binary logging and replication.</p>
<p>MySQL Error 1673: ER_BINLOG_UNSAFE_SYSTEM_VARIABLE signals that a DML or DDL statement uses a system variable that could hold different values on replicas, making it unsafe for row-based replication. Set the same variable on all servers or disable binary logging for the statement to resolve the issue.</p>
Statement is unsafe because it uses a system variable
Error 1673 appears when MySQL evaluates a statement for row-based replication and detects that it reads or writes a system variable that might not match on replicas. Because the variable value can influence the result set, logging the row events could create data drift.
The server therefore marks the statement as unsafe, blocks its execution when binlog_format is ROW, and returns SQLSTATE HY000. The protection prevents silent divergence between primary and replica instances.
The error is triggered only when binary logging is enabled and binlog_format is set to ROW or MIXED. Under STATEMENT format, the server allows the query but replication can still be inconsistent.
It commonly surfaces during schema migrations, session tuning, or data manipulation that references global or session variables such as sql_mode or time_zone.
Ignoring the warning can lead to replicas containing different data than the primary, breaking read scaling, backups, analytics, and failover safety. Addressing the root cause maintains replication integrity and avoids hard-to-debug drift.
Statements that read @@session.time_zone or similar variables are unsafe because each session can hold a different value on replicas.
Updating variables like SET GLOBAL sql_mode='STRICT_ALL_TABLES' inside a transaction can be logged before replicas apply the same change.
Creating tables with DEFAULT values that depend on system variables triggers the error since replicas might default to other values.
Triggers that access system variables during row events are flagged unsafe for the same divergence risk.
Flags INSERT IGNORE ... SELECT queries that may skip rows on replicas.
Raised when a table is simultaneously read and modified in one statement under row logging.
Occurs when inserting into tables with auto-increment columns and subqueries that can generate different row counts.
Yes, under ROW or MIXED binlog formats the server aborts the statement to protect replicas. Under STATEMENT format it runs but may cause drift.
You can disable binary logging for the session or change binlog_format, but do so only after confirming no replication risk.
Error 1673 exists in MySQL 5.6 and later because row-based replication became the default safety mechanism.
Galaxy’s linting surfaces unsafe replication patterns in the editor and its AI copilot suggests safer rewrites before you run the query.