Common SQL Errors

MySQL Error 1723 ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>CREATE TABLE … SELECT on a table containing an AUTO_INCREMENT column is unsafe for statement-based replication, so MySQL raises error 1723.</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 1723 ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC?

<p>MySQL Error 1723 ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC occurs when a CREATE TABLE … SELECT inserts into an AUTO_INCREMENT column while binlog_format is STATEMENT or MIXED. Switch to ROW binlog format or remove AUTO_INCREMENT to resolve the issue.</p>

Error Highlights

Typical Error Message

CREATE TABLE... SELECT... on a table with an

Error Type

Replication Error

Language

MySQL

Symbol

ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC

Error Code

1723

SQL State

HY000

Explanation

Table of Contents

What does error ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC mean?

MySQL raises error 1723 when it must log a CREATE TABLE … SELECT that inserts into an AUTO_INCREMENT column while binlog_format is STATEMENT or MIXED. Because the SELECT retrieval order is not deterministic, replicas can assign different AUTO_INCREMENT values, risking data drift, so the server blocks or flags the statement as unsafe.

Why is the error critical for replication?

Statement-based replication relies on executing identical SQL on source and replica. If row order differs, AUTO_INCREMENT sequences diverge, damaging primary key integrity, foreign keys and application logic. Preventing unsafe statements preserves consistency across the cluster.

How can I quickly resolve the error?

Switch the session or global binlog_format to ROW, or rewrite the operation as INSERT … SELECT after creating the table separately. Alternatively remove the AUTO_INCREMENT attribute or add ORDER BY to produce deterministic ordering then enable --binlog_rows_query_log_events.

Does MySQL version matter?

From MySQL 5.7 onward, the server may downgrade to row-based logging automatically in MIXED mode, emitting a warning instead of an error. On older versions or strict environments the statement fails entirely. Behavior also depends on sql_log_bin and slave_preserve_commit_order settings.

How can Galaxy help?

Galaxy's SQL editor highlights replication mode and warns in real time when you compose CREATE TABLE … SELECT statements with AUTO_INCREMENT columns. The AI copilot suggests row-based alternatives and can generate deterministic INSERT scripts, helping users avoid error 1723 before running the query on production.

Key takeaways

Use ROW binlog format for nondeterministic statements, avoid AUTO_INCREMENT in SELECT-based table creation, and control row order explicitly to maintain replication safety.

Common Causes

Statement-based binlog format enabled

The server or session is using binlog_format=STATEMENT or MIXED, making nondeterministic statements unsafe.

Target table has AUTO_INCREMENT

The destination table created by the statement defines an AUTO_INCREMENT primary key, so row order directly affects generated values.

No ORDER BY in SELECT clause

The SELECT pulls rows without explicit ordering, letting storage engines return rows in varying sequences across servers.

Legacy MySQL version

Older releases cannot automatically switch to ROW logging and instead raise an error for the unsafe statement.

Related Errors

MySQL Error 1725: ER_BINLOG_UNSAFE_INSERT_SELECT_AUTOINC

Raised when an INSERT … SELECT targets an AUTO_INCREMENT column under statement-based logging.

MySQL Error 1580: ER_BINLOG_UNSAFE_AUTOINC_COLUMNS

Occurs when an UPDATE modifies an AUTO_INCREMENT column nondeterministically.

MySQL Error 1592: ER_BINLOG_UNSAFE_STATEMENT

A generic warning that the preceding statement is unsafe for statement-based replication.

FAQs

Can I ignore the warning if replication uses ROW format?

If binlog_format is already ROW globally, the statement is safe and the warning can be ignored.

Does ORDER BY always guarantee safety?

An ORDER BY on a unique or primary key column produces deterministic row order, making the statement safe for statement-based logging.

Will disabling sql_log_bin bypass the error?

Yes, but the statement will not be replicated, which may leave replicas inconsistent. Use only for one-off maintenance on the primary.

Is there a performance cost to ROW format?

Row-based logging produces larger binary logs but avoids many unsafe statement problems. The trade-off is typically acceptable for safety.

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