标题: 日志报错Warning: 1592 Unsafe statement written to [打印本页] 作者: mahan 时间: 2024-9-29 14:51 标题: 日志报错Warning: 1592 Unsafe statement written to Warning: 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT
向数据库中插入时报
Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.
具体类似如下:
Warning: (1592, u’Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.’)
self._do_get_result()
原因分析: 出现这个问题的原因是 MySQL做了主-从同步后,从库对于一些特殊的字段作同步时不能安全的保证数据与主库一致,如字段id的AUTO_INCREMENT属性、使用sysdate()日期函数等。
[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 table_name
原因分析: 要插入的表table_name上有2个唯一键。则使用 INSERT… ON DUPLICATE KEY UPDATE ,且当前数据库binlog_format是statement格式,这种sql语句就会报unsafe。