How can I stop a running MySQL query?

后端 未结 7 1378
梦如初夏
梦如初夏 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 06:05

    The author of this question mentions that it’s usually only after MySQL prints its output that he realises that the wrong query was executed. As noted, in this case, Ctrl-C doesn’t help. However, I’ve noticed that it will abort the current query – if you catch it before any output is printed. For example:

    mysql> select * from jos_users, jos_comprofiler;
    

    MySQL gets busy generating the Cartesian Product of the above two tables and you soon notice that MySQL hasn't printed any output to screen (the process state is Sending data) so you type Ctrl-C:

    Ctrl-C -- sending "KILL QUERY 113240" to server ...
    Ctrl-C -- query aborted.
    ERROR 1317 (70100): Query execution was interrupted
    

    Ctrl-C can similarly be used to stop an UPDATE query.

    0 讨论(0)
提交回复
热议问题