Common SQL Errors

MySQL Error 1693 ER_BINLOG_UNSAFE_MIXED_STATEMENT - Causes, Fixes, and Prevention

Galaxy Team
August 7, 2025

<p>Occurs in MIXED binlog format when one statement touches both transactional and nontransactional tables, making the event unsafe for 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 code 1693?

<p>MySQL Error 1693 ER_BINLOG_UNSAFE_MIXED_STATEMENT arises when a statement in MIXED binlog mode reads or writes both transactional (InnoDB) and nontransactional (MyISAM) tables. Split the operation into separate, single-engine statements or switch to ROW binlog format to resolve the issue.</p>

Error Highlights

Typical Error Message

Statement accesses nontransactional table as well as

Error Type

Replication and Binary Logging Error

Language

MySQL

Symbol

ER_BINLOG_UNSAFE_MIXED_STATEMENT

Error Code

1693

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1693 ER_BINLOG_UNSAFE_MIXED_STATEMENT?

MySQL returns error 1693 with SQLSTATE HY000 when binary logging is in MIXED mode and a single SQL statement accesses transactional and nontransactional tables. The server marks the operation unsafe for replication and stops execution to protect data consistency.

The error message is Statement accesses nontransactional table as well as transactional or temporary table, and writes to any of them. Because MIXED mode chooses STATEMENT logging for many commands, combining engines can cause divergent results on replicas.

Why does this error matter?

If unsafe statements are logged, replicas can apply them differently and drift from the primary. Catching the error early prevents silent data corruption and replication stoppages later.

What Causes This Error?

The most common trigger is updating an InnoDB table and a MyISAM table in one INSERT ... SELECT, UPDATE, DELETE, or multi-table JOIN.

Creating temporary tables from a nontransactional engine inside a transaction that also modifies InnoDB rows also triggers the error.

Stored procedures or events that wrap cross-engine writes inside an implicit transaction will fail for the same reason.

How to Fix MySQL Error 1693

Split the offending statement so each part touches only one storage engine. Commit the transactional section first, then run the nontransactional section outside the transaction.

Alternatively, change the global or session binlog_format to ROW for the duration of the procedure. Row-based logging captures the exact data changes, eliminating unsafe statement detection.

Common Scenarios and Solutions

When migrating MyISAM tables to InnoDB, cross-engine INSERT ... SELECT commands frequently fail. Convert the legacy table before running the combined statement.

Reporting jobs that materialize data into MyISAM summary tables inside a transaction should run those inserts after COMMIT or switch the summary tables to InnoDB.

Best Practices to Avoid This Error

Standardize all persistent tables on a transactional engine such as InnoDB. This removes the primary cause of unsafe mixed statements.

Enable binlog_format = ROW in production clusters where mixed engines cannot be avoided. Monitor for warnings about unsafe statements during development.

Related Errors and Solutions

Error 1592 (ER_BINLOG_UNSAFE_STATEMENT) flags other unsafe statements in STATEMENT mode. Moving to ROW format fixes both.

Error 1782 (ER_BINLOG_UNSAFE_FULLTEXT_PLUGIN) appears when full-text operations are logged in STATEMENT mode. Upgrading to a transactional full-text engine or using ROW logging resolves it.

Common Causes

Cross-engine INSERT ... SELECT

An INSERT uses data from an InnoDB table to populate a MyISAM table in the same statement.

Mixed UPDATE with JOIN

An UPDATE joins a MyISAM table to an InnoDB table and modifies one or both.

Temporary MyISAM inside Transaction

Creating or populating a nontransactional temporary table while other InnoDB updates are uncommitted.

Stored Procedure with Heterogeneous Engines

A procedure wraps several DML commands on different engines inside a single BEGIN ... END block.

Related Errors

Error 1592 ER_BINLOG_UNSAFE_STATEMENT

Flags unsafe statements in STATEMENT binlog mode even without mixed engines.

Error 1782 ER_BINLOG_UNSAFE_FULLTEXT_PLUGIN

Occurs when full-text functions are logged in STATEMENT mode.

Error 1701 ER_SLAVE_THREAD

Replication stops when a slave thread encounters an unsafe or inconsistent event.

FAQs

Does this error happen in ROW binlog format?

No. Row-based logging records individual row changes, so MySQL does not consider the statement unsafe.

Can I disable the safety check?

You cannot disable it directly. The correct fix is to avoid unsafe statements or switch to ROW logging.

Why does MySQL still have MyISAM by default?

Legacy installations may retain MyISAM tables. Modern MySQL defaults to InnoDB, and you should migrate old tables.

How can Galaxy help?

Galaxy highlights storage engines in schema metadata, warns about mixed-engine queries, and lets you refactor statements quickly with its AI copilot.

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