开启binlog后异常:impossible to write to binary log since BINLOG_FORMAT = STATEMENT

问题

在实现数据库主备同步的时候,owncloud出现了异常。

General error: 1665 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.

解释

这是因为,mysql默认的binlog_format是STATEMENT。

从 MySQL 5.1.12 开始,可以用以下三种模式来实现:基于SQL语句的复制(statement-based replication, SBR),基于行的复制(row-based replication, RBR),混合模式复制(mixed-based replication, MBR)。相应地,binlog的格式也有三种:STATEMENT,ROW,MIXED。

如果你采用默认隔离级别REPEATABLE-READ,那么建议binlog_format=ROW。如果你是READ-COMMITTED隔离级别,binlog_format=MIXED和binlog_format=ROW效果是一样的,binlog记录的格式都是ROW,对主从复制来说是很安全的参数。

解决方案

方法一

mysql> STOP SLAVE;
Query OK, 0 rows affected (0.02 sec)

 mysql>  SET GLOBAL binlog_format=ROW;
Query OK, 0 rows affected (0.00 sec)

 mysql> START SLAVE;
Query OK, 0 rows affected (0.00 sec)

但是这样只是一次性的,重启后失效。

方案二

永久生效,需要修改my.ini

# binary logging format - ROW
binlog_format=ROW

参考资料:
网上资源
备注:
转载请注明出处:http://blog.csdn.net/wsyw126/article/details/73011497
作者:WSYW126

你可能感兴趣的:(MySQL)