mysql kill process解决死锁

主要是两个命令:

show processlist;
和 
kill id,id...;

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
来源:http://ri0day.blogbus.com/logs/59186177.html

mysql使用myisam的时候锁表比较多,尤其有慢查询的时候,造成死锁.这时需要手动kill掉locked的process.使他释放.

(以前我都是重起服务)..惭愧啊..

演示:(id 7是我用python 来连过来的一个会话,虽然是状态是sleep,为了演示,干掉他)

mysql> SHOW processlist;
+----+------+-----------+------+---------+------+-------+------------------+
¦ Id ¦ USER ¦ Host      ¦ db   ¦ Command ¦ TIME ¦ State ¦ Info             ¦
+----+------+-----------+------+---------+------+-------+------------------+
¦  7 ¦ root ¦ localhost ¦ yy   ¦ Sleep   ¦  154 ¦       ¦ NULL             ¦ 
¦  8 ¦ root ¦ localhost ¦ NULL ¦ Query   ¦    0 ¦ NULL  ¦ SHOW processlist ¦ 
+----+------+-----------+------+---------+------+-------+------------------+
2 ROWS IN SET (0.00 sec)
 
mysql> KILL 7
    -> ;
 
mysql> SHOW processlist;
+----+------+-----------+------+---------+------+-------+------------------+
¦ Id ¦ USER ¦ Host      ¦ db   ¦ Command ¦ TIME ¦ State ¦ Info             ¦
+----+------+-----------+------+---------+------+-------+------------------+
¦  8 ¦ root ¦ localhost ¦ NULL ¦ Query   ¦    0 ¦ NULL  ¦ SHOW processlist ¦ 
+----+------+-----------+------+---------+------+-------+------------------+
1 ROW IN SET (0.00 sec)



fatkun

54条评论

让各大学府纷纷邀请该帖作者去就如何发表优秀网络文学为题目演讲的好帖518518dfjdp

发表评论

电子邮件地址不会被公开。