1. 程式人生 > >MYSQL Error Code: 1175和Lock wait timeout exceeded處理

MYSQL Error Code: 1175和Lock wait timeout exceeded處理

Lock wait timeout exceeded解決辦法

Java執行一個SQL查詢未提交,遇到1205錯誤。

java.lang.Exception:

Error updating database.  Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

解決辦法:

執行mysql命令:show full processlist;

檢視事務表: select * from information_schema.innodb_trx;

然後找出查詢語句的系統id:kill掉被鎖住的執行緒id

(沒有看到正在執行的很慢SQL記錄執行緒,再去檢視innodb的事務表INNODB_TRX,看下里面是否有正在鎖定的事務執行緒,看看ID是否在show full processlist裡面的sleep執行緒中,如果是,就證明這個sleep的執行緒事務一直沒有commit或者rollback而是卡住了,我們需要手動kill掉)

Error Code: 1175

MySql 執行 DELETE FROM Table 時,報

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.

錯誤,這是因為 MySql 執行在 safe-updates模式下,該模式會導致非主鍵條件下無法執行update或者delete命令,執行命令如下命令

SET SQL_SAFE_UPDATES = 0;