当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL:Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEM

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

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配置问题,大家可以参考这篇文章:

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网