mysql error:Lock wait timeout exceeded; try restarting transaction

  Mysql 中执行 update 时报错:Lock wait timeout exceeded; try restarting transaction。

  锁等待超时,是由于当前事务等待其他事务释放锁资源造成的,默认等待时间为 50s, 由mysql配置参数 innodb_lock_wait_timeout 配置。

SHOW VARIABLES LIKE '%innodb_lock_wait_timeout%'; #查看锁等待时间

  查看是否有锁定的事务线程:

select * from information_schema.innodb_trx;

  再查看当前数据库当前线程情况,如果有 sleep 状态的线程在上面的锁定线程中,直接kill掉线程。(事务表中的trx_mysql_thread_id为线程号)

show full processlist;

  

  kill 掉线程

kill thread_id
原文地址:https://www.cnblogs.com/chenyongjun/p/4618776.html