欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MySQL:Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEM

程序员文章站 2024-02-21 10:07:39
1:错误日志大量错误 150602 14:40:02 [warning] unsafe statement written to the binary log using...

1:错误日志大量错误

150602 14:40:02 [warning] unsafe statement written to the binary log using statement format since binlog_format = statement. insert... select... on duplicate key update is unsafe because the order in which rows are retrieved by the select determines which (if any) rows are updated. this order cannot be predicted and may differ on master and the slave. statement:insert into tab_name
  

2:原因:

查了下原因,tab_name 这个表上有2个唯一键。则使用insert … on duplicate key update ,且当前数据库binlog_format是statement格式,这种sql语句就会报unsafe。
  

官方手册:

insert … on duplicate key update statements on tables with multiple primary or unique keys.when executed against a table that contains more than one primary or unique key, this statement is considered unsafe, being sensitive to the order in which the storage engine checks the keys, which is not deterministic, and on which the choice of rows updated by the mysql server depends.
  

解决方法:

把binlog_format设置为row或者statement或者修改sql。

一般情况下就是mysql配置问题,大家可以参考这篇文章: