zoukankan      html  css  js  c++  java
  • MySQL中kill所有慢查询进程和锁表进程

    1、kill所有慢查询进程:

    #!/bin/bash
    mysql -uroot -pMy_Password -e "show processlist" | grep -i "Query" > slow_query.log
    
    for query in `cat slow_query.log | awk '{print $1}'`
    do
       echo "kill $query;" > kill_slow_query.sql
    done

    登录mysql,执行:

    mysql> source kill_slow_query.sql

    或者:

    #!/bin/bash
    for query in `mysqladmin -uroot -pMy_Password processlist | grep -i 'Query' | awk '{print $2}'`
    do
       mysqladmin kill ${query}
    done

    2、kill所有死锁进程:

    #!/bin/bash
    mysql -uroot -pMy_Password -e "show processlist" | grep -i "Locked" > locked.log
    
    for lock in `cat locked.log | awk '{print $1}'`
    do
       echo "kill $lock;" > kill_locked.sql
    done

    登录mysql,执行:

    mysql> source kill_locked.sql

    或者:

    #!/bin/bash
    for lock in `mysqladmin -uroot -pMy_Password processlist | grep -i 'Locked' | awk '{print $2}'`
    do
       mysqladmin kill ${lock}
    done
  • 相关阅读:
    类特性:多态
    类特性:继承
    类,对象入门
    cf round599 CDE
    cf round#598 CDEF
    高精度小数BigDecimal+二分——java
    点分治
    java——IO(普通文件,二进制文件,压缩文件 )
    JCF——Map
    JCF——set
  • 原文地址:https://www.cnblogs.com/fansik/p/7054869.html
Copyright © 2011-2022 走看看