美文网首页
MySQL线程管理(持续更新)

MySQL线程管理(持续更新)

作者: 这货不是王马勺 | 来源:发表于2021-11-16 10:49 被阅读0次

杀掉一个用户的全部线程:

select concat('KILL ',id,';') from information_schema.processlist 
where user='wenjie.wang';  

将拼好的语句拿出来执行即可。

杀掉一个库的全部线程:

select concat('KILL ',id,';') from information_schema.processlist 
where DB='testDB';  

筛选processlist:

select id,user,host,db,command,time,state,info 
from information_schema.processlist;

查看阻塞:

SELECT 
    waiting_pid as '被阻塞线程',
    waiting_query as '被阻塞SQL',
    blocking_pid as '阻塞线程',
    blocking_query as '阻塞SQL',
    wait_age as '阻塞时间'
FROM
    sys.innodb_lock_waits
WHERE
    (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(wait_started)) > 30
;

相关文章

网友评论

      本文标题:MySQL线程管理(持续更新)

      本文链接:https://www.haomeiwen.com/subject/bcchtrtx.html