How to Fix MySQL Error 1693 (ER_BINLOG_UNSAFE_MIXED_STATEMENT)
You trigger mysql error 1693 when one statement accesses a nontransactional table and a transactional or temporary table while writing to any of them. You fix this issue by splitting the query into separate steps or converting all tables to a transactional engine. The official symbol for this database issue is ER_BINLOG_UNSAFE_MIXED_STATEMENT with SQLSTATE HY000. It warns teams that statement-based replication can go out of sync across replicas. When a transaction rolls back, nontransactional t
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You trigger mysql error 1693 when one statement accesses a nontransactional table and a transactional or temporary table while writing to any of them. You fix this issue by splitting the query into separate steps or converting all tables to a transactional engine.
The official symbol for this database issue is ER_BINLOG_UNSAFE_MIXED_STATEMENT with SQLSTATE HY000. It warns teams that statement-based replication can go out of sync across replicas. When a transaction rolls back, nontransactional tables keep their new rows while transactional tables revert. This split behavior breaks data integrity between your primary database and replica nodes.
Why mysql error 1693 happens in database engines
Database engines handle writes in two distinct ways. Transactional engines group changes together so they succeed or fail as one unit. Nontransactional engines write each change to disk right away without rollback support. Temporary tables often add extra complexity to how the binary log records events.
When your app runs a single query that touches both table types and writes data, the binary log faces a conflict. If that query fails halfway through, the nontransactional table keeps the partial write. The transactional table undoes its work. Yet the binary log may record the event in a way that replicas replay in a different order.
Legacy systems often mix older nontransactional tables with newer transactional tables in the same schema. Reporting jobs also create temporary tables and join them against permanent tables during updates. Both patterns trigger this warning or failure when binary logging is active.
How to find the mixed query in production
Start by checking your database error logs and slow query logs to find the exact query. Look for statements that join multiple tables and include an insert, update, or delete action. Check the storage engine type for every table involved in that query.
You do not need to grant broad admin rights to developers during this check. Give read-only metadata roles to your team so they can inspect table schemas safely. They can view the storage engine details from the system catalog without touching live user rows.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also check if the session creates temporary tables before running the failing write statement. Many reporting scripts build a temporary table to hold intermediate numbers and then update a permanent log table. If either table lacks transaction support, the database raises error 1693.
How to fix the error without disabling safety checks
Never disable binary logging or turn off replication safety checks to hide this warning. Doing so puts your backup recovery and replica consistency at serious risk. Instead, fix the underlying table design or query structure.
The cleanest fix is to convert your nontransactional tables to a transactional storage engine. Plan this change during a low-traffic window because table conversion rebuilds the table data. Test the change in a staging setup first to check that your app queries still run fast.
If you cannot change the table engine right away, split the single statement into two separate queries. First, read the needed rows from the source table into your app memory. Second, write those values to the target table in a standalone statement. You can also switch your binary log format to row-based logging, which records actual row changes instead of raw statements.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
What does ER_BINLOG_UNSAFE_MIXED_STATEMENT mean in MySQL?
It means a single statement accesses a nontransactional table alongside a transactional or temporary table and writes to at least one of them. This mix makes statement-based binary logging unsafe for replication.
Can row-based binary logging prevent mysql error 1693?
Yes, row-based logging records individual row changes rather than the raw query text. This approach avoids ambiguity when replaying changes on replica servers, though converting tables to transactional engines remains best practice.
Why do temporary tables trigger this binary log error?
Temporary tables often use different transaction rules or memory engines than permanent tables. Combining them with nontransactional tables in a write query creates the same rollback mismatch risk for the binary log.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post