Common SQL Errors

MySQL Error 1664: ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE - Fix and Prevention Guide

Galaxy Team
August 7, 2025

<p>The server cannot write the current transaction to the binary log because row-based logging is active while at least one table relies on a statement-only storage engine.</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 1664?

<p>MySQL Error 1664 ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE happens when row-based binlogging meets a statement-only storage engine. Set binlog_format to STATEMENT or migrate the affected tables to InnoDB to resolve the conflict.</p>

Error Highlights

Typical Error Message

Cannot execute statement: impossible to write to binary

Error Type

Binary Logging Error

Language

MySQL

Symbol

ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE

Error Code

1664

SQL State

HY000

Explanation

Table of Contents

What does MySQL Error 1664 ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE mean?

The error appears with the message "Cannot execute statement: impossible to write to binary log since statement is in row format and at least one table uses a storage engine limited to statement-based logging." MySQL refuses to proceed because it cannot safely record the transaction in its binary log.

When does Error 1664 occur?

The problem surfaces during INSERT, UPDATE, DELETE, or LOAD DATA operations when the server is configured for ROW or MIXED binlog_format, yet one of the referenced tables uses a storage engine that only supports STATEMENT logging, such as BLACKHOLE or MEMORY in older versions.

Why is Error 1664 critical to resolve quickly?

If the transaction is skipped, replication slaves will miss data changes, leading to drift between primary and replicas. This inconsistency can corrupt reports, backups, and failover procedures. Fixing the logging conflict preserves data integrity across the cluster.

Key properties of the error

Error Code: 1664. SQLSTATE: HY000. Condition Name: ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE. Scope: Binary logging and replication. Affected Versions: MySQL 5.7 and 8.0 when using row or mixed logging with statement-only engines.

Impact on applications

Applications experience an immediate SQL exception, and the current transaction rolls back. High-throughput services may see elevated latency and retries until the underlying binlog configuration mismatch is corrected.

Common Causes

Mixed logging formats

binlog_format is set to ROW or MIXED but some tables require STATEMENT logging, creating an unresolvable mismatch during runtime.

Unsupported storage engines

Tables stored in MEMORY, BLACKHOLE, or custom plugins that do not support row-based logging trigger the error whenever data-changing statements target them.

Per-session binlog changes

Developers sometimes switch binlog_format to ROW inside sessions for debugging, forgetting to revert it before running code that touches statement-only tables.

Legacy code paths

Stored procedures or triggers created under STATEMENT mode still operate, but servers later upgraded to ROW mode expose the conflict when they execute.

Related Errors

MySQL Error 1592 - ER_BINLOG_FORMAT_MISMATCH

Occurs when the server cannot replicate because the binlog format differs between master and slave.

MySQL Error 1598 - ER_BINLOG_ROW_INJECTION_AND_STMT_MODE

Raised when a row-based event is attempted in STATEMENT mode.

MySQL Error 1467 - ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE

Indicates a conflict between storage engines when mixing row and statement replication types.

FAQs

Can I ignore MySQL error 1664?

No. Ignoring it risks replication gaps and data loss on replicas.

Which storage engines are incompatible with row logging?

BLACKHOLE, MEMORY in some versions, and custom engines that do not implement row events.

Is switching to STATEMENT logging safe?

It resolves the error but reduces replication safety for non-deterministic queries. Prefer converting tables to InnoDB.

How does Galaxy help?

Galaxy flags errors instantly, offers AI-generated fixes, and lets teams convert engines or toggle binlog_format from an integrated, version-controlled editor.

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