前言
    binlog有三种格式,分别是STATEMENT、row、mixed。每种格式的区别可以去看复制那篇文章,那它分别与read committed 有什么关系呢。下面以例子来分析

1、数据库版本
   mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.45, for unknown-linux-gnu (x86_64) using  EditLine wrapper

Connection id:          2
Current database:       xinying
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.45-VS-log XinYing
Protocol version:       10
Connection:             Localhost via UNIX socket
Insert id:              2
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /tmp/mysql.sock
Uptime:                 1 hour 40 min 14 sec

2、改变事务级别为read committed
 
  mysql>set session transaction isolation level read committed;
  Query OK, 0 rows affected (0.00 sec)
3、改变二进制日志格式
 
  mysql>set binlog_format=STATEMENT;
  Query OK, 0 rows affected (0.00 sec)
4、创建测试表
  mysql>CREATE TABLE `slevin` (
      ->`id` int(10) NOT NULL AUTO_INCREMENT,
      ->`book` char(10) DEFAULT NULL,
      ->PRIMARY KEY (`id`)
      ->) ENGINE=InnoDB;
  Query OK, 0 rows affected (0.03 sec)

5、插入数据测试
  mysql>insert into slevin(book) values('wuli');
  ERROR 1598 (HY000): Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'

看到没,提示出错,那我们尝试把事务基本改为REPEATABLE READ
  mysql>
set session transaction isolation level REPEATABLE READ;
  Query OK, 0 rows affected (0.00 sec)
 
  mysql>insert into slevin(book) values('wuli');
  Query OK, 1 row affected (0.00 sec)

 改个事务级别就成功了,那试试仍旧把它改为read committed,把binlog格式改了试试

 mysql>set session transaction isolation level read committed;
 Query OK, 0 rows affected (0.00 sec)

 mysql>set session binlog_format=row;   改为行格式
 Query OK, 0 rows affected (0.00 sec)

 mysql>insert into slevin(book) values('wuli');
 Query OK, 1 row affected (0.00 sec)

 mysql>set session binlog_format=mixed; 改为混合格式
 Query OK, 0 rows affected (0.00 sec)

 mysql>insert into slevin(book) values('wuli');
 Query OK, 1 row affected (0.00 sec)

把上面改为两种格式都成功,唯独STATEMENT格式不行,所以以后要注意read committed与binlog格式的关系,否则会导致插入不了数据。为何会导致这种情况呢,那是因为read committed可能会导致不可重复读,也就是说可以读取到后面进入并提交的数据,如果基于STATEMENT格式的话,会导致主从数据不一样,因为STATEMENT是基于SQL语句的复制模式。

另外设置innodb_locks_unsafe_for_binlog=1 ,binlog也要设为row格式。具体请看 http://blog.chinaunix.net/u3/99514/showart_1974703.html这篇文章详细了解。