1. 程式人生 > 其它 >mysql刪除500資料_MySQL資料刪除異常

mysql刪除500資料_MySQL資料刪除異常

技術標籤:mysql刪除500資料

具體報錯資訊如下:

exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1175 You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column' in /xxxx/storage/db/adapter/PDOAbstract.php:776

意思是where條件是一個非key的列且無limit,原因在於mysql設定了sql_safe_updates為ON,通過以下方式檢視

c780ae11f6d5e7238ee2ceda6c22e100.png

兩種解決方法:

1 把該列設定成key即可

alter table tablename add index `idx_column_name` (column_name)

2 修改mysql配置

set sql_safe_updates=0; 或 set sql_safe_updates=off;