MySQL drop空表时处于Waiting for table metadata lock状态,解决办法

#将以下语句修改一下后复制粘贴到linux命令行
方法1:
alias  db_conn="mysql -h 127.0.0.1 -uroot -proot@123 -P 3320"
db_conn -ss -e " select concat("kill ",b.ID,";") as kill_id from information_schema.INNODB_TRX a,information_schema.PROCESSLIST b where a.trx_mysql_thread_id=b.ID and a.trx_state='RUNNING' and b.TIME >=30; "|db_conn

方法2:
alias  db_conn="mysql -h 127.0.0.1 -uroot -proot@123 -P 3320"
db_conn -ss -e "select concat("kill ",trx_mysql_thread_id,";") as kill_id from information_schema.INNODB_TRX where trx_lock_structs=0 and trx_weight=0 and trx_rows_locked=0 and trx_rows_modified=0 and trx_state='RUNNING';"|db_conn

版权声明:QQ:597507041

原文地址:https://www.cnblogs.com/spzhangfei/p/4801773.html