How can I stop a running MySQL query?

后端 未结 7 1418
梦如初夏
梦如初夏 2020-12-04 05:05

I connect to mysql from my Linux shell. Every now and then I run a SELECT query that is too big. It prints and prints and I already know this is no

7条回答
  •  囚心锁ツ
    2020-12-04 05:54

    If you have mysqladmin available, you may get the list of queries with:

    > mysqladmin -uUSERNAME -pPASSWORD pr
    
    +-----+------+-----------------+--------+---------+------+--------------+------------------+
    | Id  | User | Host            | db     | Command | Time | State        | Info             |
    +-----+------+-----------------+--------+---------+------+--------------+------------------+
    | 137 | beet | localhost:53535 | people | Query   | 292  | Sending data | DELETE FROM      |
    | 145 | root | localhost:55745 |        | Query   | 0    |              | show processlist |
    +-----+------+-----------------+--------+---------+------+--------------+------------------+
    

    Then you may stop the mysql process that is hosting the long running query:

    > mysqladmin -uUSERNAME -pPASSWORD kill 137
    

提交回复
热议问题