Common SQL Errors

MySQL Error 1670: ER_BINLOG_UNSAFE_SYSTEM_TABLE - Causes, Fixes, and Prevention

Galaxy Team
August 7, 2025

<p>MySQL raises ER_BINLOG_UNSAFE_SYSTEM_TABLE when a statement that touches general_log, slow_log, or performance_schema tables is written to the binary log, because replicas may not have identical system tables.</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 1670 (ER_BINLOG_UNSAFE_SYSTEM_TABLE)?

<p>MySQL Error 1670: ER_BINLOG_UNSAFE_SYSTEM_TABLE signals that a statement touching general_log, slow_log, or performance_schema tables cannot be safely written to the binary log, risking replication drift. Disable binlogging for the session or rewrite the query to avoid those system tables to fix the issue.</p>

Error Highlights

Typical Error Message

The statement is unsafe because it uses the general log,

Error Type

Replication/Binary Logging Error

Language

MySQL

Symbol

ER_BINLOG_UNSAFE_SYSTEM_TABLE

Error Code

1670

SQL State

HY000

Explanation

Table of Contents

What does MySQL Error 1670 (ER_BINLOG_UNSAFE_SYSTEM_TABLE) mean?

MySQL throws this error when a statement that modifies or selects from system logging tables would be recorded in the binary log. Because replicas may store these tables differently, logging such statements could break deterministic replication.

The server blocks the statement and returns SQLSTATE HY000 to prevent replication mismatches. Understanding why the table is unsafe is the first step toward remediation.

Why is the error considered “unsafe” for replication?

System tables like general_log, slow_log, and performance_schema are local to each node. They can be enabled, disabled, or truncated independently. Writing them to the binlog means replicas might replay statements that do not apply or collide with their own settings, leading to divergent states.

When does the error usually appear?

The error appears during INSERT, UPDATE, DELETE, CREATE TABLE AS SELECT, or SELECT ... INTO OUTFILE statements that reference one of the flagged system tables while binary logging is enabled and binlog_format is STATEMENT or MIXED.

Why is fixing this important?

Ignoring the warning and forcing the statement through can corrupt replication, cause replication lag, or require time-consuming re-syncs. Addressing it early protects data integrity across the cluster.

Common Causes

Direct writes to general_log or slow_log

INSERT or CREATE TABLE AS SELECT commands that move diagnostic data into permanent tables will trigger the error when binary logging is on.

Queries against performance_schema in STATEMENT or MIXED mode

Reading or joining performance_schema tables inside multi-table statements can be flagged as unsafe because result sets differ per server.

Session leaves binlog_format at STATEMENT

Many applications rely on default STATEMENT mode. Any statement using system tables under this format is automatically marked unsafe.

Truncation or deletion of logging tables

TRUNCATE TABLE general_log or DROP TABLE performance_schema.* operations are blocked to avoid wiping log data only on replicas.

Related Errors

ER_BINLOG_UNSAFE_MIXED_STATEMENT (1592)

Raised when a statement is unsafe in MIXED mode for reasons other than system tables.

ER_BINLOG_UNSAFE_AUTOINC_COLUMNS (1166)

Occurs when non-deterministic auto-increment behavior makes statement logging unsafe.

ER_BINLOG_LOGGING_IMPOSSIBLE (1618)

Triggered when logging cannot proceed due to missing privileges or disk space.

FAQs

Can I ignore the error with super privileges?

SET GLOBAL sql_log_bin = 0 requires SUPER or SYSTEM_VARIABLES_ADMIN, but ignoring the error risks replica divergence.

Does ROW format always fix the error?

Yes, ROW format logs exact row images, so system table differences do not matter. Ensure the change does not impact performance.

Will disabling binlogging harm backups?

Turning off sql_log_bin only for a session or statement does not affect global binary logs or incremental backup strategies.

How does Galaxy help avoid unsafe statements?

Galaxy highlights system table usage and suggests setting binlog_format to ROW or disabling binlog before execution, reducing human error.

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