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

  • 2021-01-19 22:28:23
  • OfStack

1: Error log a large number of errors

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. Reasons:

tab_name table has two only 1 keys. ES11en is used... ON DUPLICATE KEY UPDATE, and if the current database binlog_format is in statement format, this sql statement will be reported as unsafe.

Official Handbook:

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.

Solution:

Set binlog_format to ROW or STATEMENT or modify SQL.

1 case is mysql configuration problem, everyone can refer to this article: https: / / www ofstack. com article / 84357. htm


Related articles: