How can I stop a running MySQL query?

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 not what I meant. I would like to stop the query.

Hitting Ctrl+C (a couple of times) kills mysql completely and takes me back to shell, so I have to reconnect.

Is it possible to stop a query without killing mysql itself?

mysql>show processlist;

kill "number from first col";

Related Posts

  • 53
    A Shell script for killing slow MySQL queries: #!/bin/sh # Credentials for a MySQL user with PROCESS, SUPER permissions USERNAME= PASSWORD= # MySQL Server location HOST= PORT=3306 TIMEOUT=60 # 1 minute TARGET_USER= # MySQL user to monitor MYSQL="mysql -u $USERNAME --password=$PASSWORD -h $HOST -P $PORT -B" $MYSQL -N -e 'SHOW…
    Tags: mysql, kill, linux, processlist, shell, killing, query
  • 48
    Summary: in this tutorial, you are going to learn about MySQL View. We will explain how MySQL implements views. MySQL supports database views or views since version 5.X. In MySQL, almost features of views conform to the SQL: 2003 standard. MySQL process queries to the views in two ways: MySQL creates a temporary table…
    Tags: mysql, query
  • 46
    The core logic of a database application is performed through SQL statements, whether issued directly through an interpreter or submitted behind the scenes through an API. The tuning guidelines of this post will help to speed up all kinds of MySQL applications. The guidelines cover SQL operations that read and…
    Tags: query, select, mysql
  • 43
    Easiest way to do this is to add a UNIQUE index on the column. When you write the ALTER statement, include the IGNORE keyword. Like so: ALTER IGNORE TABLE jobs ADD UNIQUE INDEX idx_name (site_id, title, company); This will drop all the duplicate rows. As an added benefit, future INSERTs…
    Tags: running, mysql, query
  • 41
    Very often we need to extract last 30 days, 7 days data from mysql DB. Here we will show easy way to get the data of given interval. SELECT DATE_FORMAT(create_date, '%m/%d/%Y') FROM mytable WHERE create_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() Also note that CURDATE() returns only the DATE…
    Tags: select, mysql, query

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: