Error
Error Code:
1661
MySQL Error 1661: Mixed Engine Binlog Conflict
Description
This error occurs when MySQL attempts to write to the binary log during a transaction that involves tables from different storage engines. It signifies an inability to consistently log the transaction for replication or recovery purposes, as some involved engines are incompatible with row-based logging and others with statement-based logging.
Error Message
Cannot execute statement: impossible to write to binary log since both row-incapable engines and statement-incapable engines are involved.
Known Causes
3 known causesIncompatible Storage Engines
A single SQL statement or transaction accesses tables that use storage engines with fundamentally different binary logging capabilities.
Mixed-Engine Schema Operations
Executing DDL or DML statements that affect tables across different storage engines within a schema configured for binary logging.
Complex Statements with Temporary Tables
Advanced SQL operations, especially those involving temporary tables or views, can expose binlog conflicts when interacting with mixed engine types.
Solutions
3 solutions available1. Migrate Tables to a Compatible Storage Engine medium
Convert tables using incompatible storage engines to a single, compatible engine like InnoDB.
1
Identify tables using non-transactional (e.g., MyISAM) or statement-based replication incompatible engines.
SELECT TABLE_SCHEMA, TABLE_NAME, ENGINE FROM information_schema.TABLES WHERE ENGINE NOT IN ('InnoDB', 'NDB');
2
For each identified table, alter its storage engine to InnoDB. This is the most common and recommended engine for binlog compatibility.
ALTER TABLE your_table_name ENGINE=InnoDB;
3
After migrating all tables, restart the MySQL server to ensure the changes are fully applied.
sudo systemctl restart mysql
2. Disable Binary Logging Entirely (Not Recommended for Replication) easy
Turn off binary logging if replication is not a requirement.
1
Edit your MySQL configuration file (e.g., `my.cnf` or `my.ini`).
2
Locate the `[mysqld]` section and comment out or remove the `log_bin` directive.
[mysqld]
# log_bin = /var/log/mysql/mysql-bin.log
3
Save the configuration file and restart the MySQL server.
sudo systemctl restart mysql
3. Configure Binlog Format for Compatibility medium
Change the binary log format to `ROW` to ensure compatibility with all engines.
1
Edit your MySQL configuration file (e.g., `my.cnf` or `my.ini`).
2
Under the `[mysqld]` section, set `binlog_format` to `ROW`.
[mysqld]
binlog_format = ROW
3
Save the configuration file and restart the MySQL server.
sudo systemctl restart mysql
4
Note: While `ROW` format is generally compatible, it can generate larger binlogs. Ensure your storage and network can handle this. If you still encounter issues after this, it strongly suggests a persistent issue with non-transactional engines that need migration.