How to Fix MySQL Error 1662 (ER_BINLOG_ROW_MODE_AND_STMT_ENGINE)
You get mysql error 1662 when a query touches a table with a statement-only storage engine while the binary log uses row mode. You can fix it by changing the binary log mode to statement or mixed, or by moving the table to a storage engine that supports row logging. This failure stops write queries right away. The database blocks the change to keep replication safe across your servers. When your team knows how logging modes and storage engines work together, you can fix the issue fast without r
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 get mysql error 1662 when a query touches a table with a statement-only storage engine while the binary log uses row mode. You can fix it by changing the binary log mode to statement or mixed, or by moving the table to a storage engine that supports row logging.
This failure stops write queries right away. The database blocks the change to keep replication safe across your servers. When your team knows how logging modes and storage engines work together, you can fix the issue fast without risking data loss.
What causes mysql error 1662 in your database
MySQL uses the binary log to record data changes for backups and replication. The server lets you run this log in row mode, statement mode, or mixed mode. In row mode, the database logs the exact changes made to each individual table row. In statement mode, the database logs the exact SQL query that ran.
When mysql error 1662 happens, the server returns SQLSTATE HY000 and the symbol ER_BINLOG_ROW_MODE_AND_STMT_ENGINE. The official message states that the database cannot run the statement because the binary log format is set to row while at least one table uses a storage engine limited to statement logging.
Most standard tables use a general storage engine that supports both row and statement logging. Still, some special storage engines only know how to log whole SQL statements. They cannot report row-by-row data changes back to the binary log system. If your session or server forces row mode, the engine and the log clash. The database then stops the query before any data changes happen.
How to diagnose the failing query and table engine
Start by finding the exact query that failed in your app logs. Look at every table name inside that query. Include tables hidden inside views or triggers that the main query calls. Even a trigger that writes to a secondary audit table can set off this error.
Next, ask the database metadata for the storage engine of each table in that list. You will find at least one table that uses a specialized engine built only for statement logging. You should also check the current binary log format for both the global server and the active client session.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Sometimes the global server uses mixed mode, which works fine for most workloads. Yet an app or migration tool might switch its own session to row mode right before running queries. Finding out where row mode gets turned on helps you pick the safest fix.
How to fix the binary log conflict safely in production
You have two safe ways to fix this error in a live system. First, you can switch the binary log format from row mode to mixed mode or statement mode. Mixed mode is often the safest choice for general workloads. It uses statement logging when needed and row logging when possible. You can test this change at the session level before you update the global server setting.
Note that changing the log format requires admin rights if you apply it to the whole server. Do not give full admin rights to app roles just to let them switch session log settings. Instead, have a database admin update the server rule or fix the app setup.
Second, you can alter the problem table so it uses a standard transactional storage engine. A standard engine supports row-based logging without any conflict. Before you change a table engine in production, check why the old engine was chosen. Make sure the new engine supports your data types and query patterns, then run the change during low traffic.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Does mysql error 1662 corrupt data on replicas?
No, this error prevents data corruption before it can start. The primary database blocks the query before writing anything to disk or the binary log, so replicas stay in sync.
Why did this error appear after a database change?
A recent update or admin task may have switched the default binary log mode to row. If you have older tables using statement-only engines, queries against them will start failing right away.
Can a read query trigger mysql error 1662?
Plain read queries do not write to the binary log and will not trigger this error. Still, a query that selects data and inserts it into a temporary or log table can cause the failure.
Related guides
In this post