1.在MySQL中,如何查看哪个表被锁了?

show open tables where in_use>0;


2.判定某个表有没有加锁?

show open tables where table like 'tbl_name' and in_use>0;


3.哪个进程对这个表进行了加锁?


mysqladmin debug
注:它可以与show [full] processlist; 命令结合使用。
如果存储引擎是innodb还可以使用show [engine] innodb status;



4.确定哪个进程后,可以是使用kill命令将其杀死

kill put_process_id_here;


:除了mysqladmin debug是在shell下执行的,其余的都是在mysql的上下文执行的!