Common SQL Errors

MySQL Error 1673: ER_BINLOG_UNSAFE_SYSTEM_VARIABLE - Fix Unsafe System Variable Replication Issues

Galaxy Team
August 7, 2025

<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>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1673?

<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>

Error Highlights

Typical Error Message

Statement is unsafe because it uses a system variable

Error Type

Replication Error

Language

MySQL

Symbol

ER_BINLOG_UNSAFE_SYSTEM_VARIABLE

Error Code

1673

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1673 (ER_BINLOG_UNSAFE_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.

When does this error occur?

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.

Why is fixing it important?

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.

Common Causes

Using SESSION system variables

Statements that read @@session.time_zone or similar variables are unsafe because each session can hold a different value on replicas.

Modifying GLOBAL variables inside a transaction

Updating variables like SET GLOBAL sql_mode='STRICT_ALL_TABLES' inside a transaction can be logged before replicas apply the same change.

Mixing DDL and variable reads

Creating tables with DEFAULT values that depend on system variables triggers the error since replicas might default to other values.

Row-based triggers referencing variables

Triggers that access system variables during row events are flagged unsafe for the same divergence risk.

Related Errors

MySQL Error 1671: ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT

Flags INSERT IGNORE ... SELECT queries that may skip rows on replicas.

MySQL Error 1672: ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE

Raised when a table is simultaneously read and modified in one statement under row logging.

MySQL Error 1701: ER_BINLOG_UNSAFE_AUTOINC_COLUMNS

Occurs when inserting into tables with auto-increment columns and subqueries that can generate different row counts.

FAQs

Does the error stop the statement from running?

Yes, under ROW or MIXED binlog formats the server aborts the statement to protect replicas. Under STATEMENT format it runs but may cause drift.

Can I turn off the safety check?

You can disable binary logging for the session or change binlog_format, but do so only after confirming no replication risk.

Which MySQL versions show this error?

Error 1673 exists in MySQL 5.6 and later because row-based replication became the default safety mechanism.

How does Galaxy help avoid this?

Galaxy’s linting surfaces unsafe replication patterns in the editor and its AI copilot suggests safer rewrites before you run the query.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo