Common SQL Errors

MySQL Error 1667: ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>The server refuses to write a statement to the binary log because it touches tables from multiple engines and at least one of them already logs independently.</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 1667 ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE?

<p>MySQL Error 1667 ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE occurs when a single statement mixes self-logging engines like NDB with other engines, blocking binary logging. Split the statement by engine or disable binlog for the session to resolve the issue.</p>

Error Highlights

Typical Error Message

Cannot execute statement: impossible to write to binary

Error Type

Binary Log Error

Language

MySQL

Symbol

ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE

Error Code

1667

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1667 ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE?

The error appears with the message Cannot execute statement: impossible to write to binary log since more than one engine is involved and at least one engine is self-logging. It is triggered during statement execution when MySQL must record the operation in the binary log for replication or point-in-time recovery.

The server detects that the statement accesses tables handled by multiple storage engines and that at least one of those engines, such as NDB, manages its own binary logging. Mixing self-logging and regular engines would create duplicate or inconsistent events, so MySQL blocks the write.

What Causes This Error?

MySQL raises error 1667 when a single SQL statement accesses tables from both a self-logging engine (NDB, MyRocks with binlog on, etc.) and a non-self-logging engine (InnoDB, MyISAM, MEMORY). The conflict prevents safe unified binary logging.

The error can also surface if a trigger, foreign key, or stored routine causes hidden access to a different engine within the same statement, silently combining engines.

How to Fix MySQL Error 1667

Split multi-engine operations into separate statements so each statement touches only one engine type. MySQL can then log the events safely.

An alternative is to turn off binary logging for the session with SET sql_log_bin = 0 when replication safety is not required, though this should be limited to maintenance windows.

Common Scenarios and Solutions

Updating an InnoDB table while reading from an NDB table in one INSERT ... SELECT triggers the error. Rewrite as two steps: first insert data into a temp InnoDB table, then update the target.

Complex stored procedures sometimes call both NDB and InnoDB tables. Refactor the logic so that NDB operations happen in a separate procedure executed with logging disabled or located on an NDB-only SQL node.

Best Practices to Avoid This Error

Keep workloads homogeneous by engine within a single statement. Design schemas so that tables participating in frequent joins or DML belong to the same engine family.

Enable static code analysis in Galaxy or your CI pipeline to flag mixed-engine statements before deployment. Galaxy’s AI copilot can suggest rewrites that isolate storage engines per statement.

Related Errors and Solutions

Error 1888 ER_BINLOG_UNSAFE_STATEMENT warns about unsafe non-transactional changes. The fix is similar: split statements and use transactional engines.

Error 1223 SQLSTATE HY000 sets off when a statement fails inside a stored routine with logging disabled. Re-enable sql_log_bin or restructure the routine.

Common Causes

Mixing NDB and InnoDB in one statement

An INSERT ... SELECT or multi-table UPDATE reads NDB while writing InnoDB, so MySQL blocks logging.

Triggers or FK cascading to another engine

The main table is InnoDB, but a trigger updates an NDB audit table, creating a hidden multi-engine statement.

Self-logging plugin engines

Engines that emit their own binlog events clash with standard logging when combined with regular engines.

Related Errors

ER_BINLOG_UNSAFE_STATEMENT (Code 1592)

Statement is unsafe for statement-based replication. Fix by switching to row format or rewriting the query.

ER_BINLOG_LOGGING_IMPOSSIBLE (Code 1598)

Occurs when trying to log to a disabled or full binary log. Ensure log_bin is enabled and log file has space.

ER_UNKNOWN_STORAGE_ENGINE (Code 1286)

Engine not supported or disabled. Load the plugin or choose a valid engine.

FAQs

Does this error affect row-based replication?

Yes. Even with row logging, combining self-logging and non-self-logging engines can duplicate events, so MySQL prevents it.

Can I ignore the error by forcing the query?

No. The server will block execution until the statement is rewritten or binary logging is disabled for that session.

Which MySQL versions raise error 1667?

All GA versions from 5.6 onward that support NDB Cluster or other self-logging engines enforce this restriction.

How can Galaxy help avoid this error?

Galaxy’s AI copilot flags mixed-engine statements in the editor and suggests splitting them, preventing the error before run time.

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