Search the MySQL manual:
Subscribe to the monthly
MySQL Newsletter!

4.5.5 Синтаксис команды KILL

KILL thread_id

Каждое соединение с mysqld запускается в отдельном потоке. При помощи команды SHOW PROCESSLIST можно просмотреть список запущенных потоков, а при помощи команды KILL thread_id - удалить поток.

Если у вас есть привилегия PROCESS, можно просмотреть все потоки. Обладая привилегией SUPER, можно удалять любые потоки. В противном случае можно просматривать и удалять только свои собственные потоки.

Для просмотра и удаления потоков можно также применять команды mysqladmin processlist и mysqladmin kill.

При использовании команды KILL для потока устанавливается специальный флаг kill flag.

В большинстве случаев удаление потока занимает некоторое время, поскольку этот флаг проверяется с определенным интервалом.

User Comments

Posted by [name withheld] on July 10 2003 8:41am[Delete] [Edit]

Would be advantageous to have an immediate kill command - currently have a v3.23 db that is locked up (I believe waiting on a thread) the thread cannot be killed so the only hope I have is to kill the whole db :(

Posted by Lyle Worthington on November 23 2003 8:33am[Delete] [Edit]

I am using version 4.0.15-standard and I had the same problem! A thread was stuck in the "Killed" state for 12000 seconds. I gave in and killed the server, then had to endure a nasty rollback.

Posted by [name withheld] on November 26 2003 5:12pm[Delete] [Edit]

Same problem here:

mysqladmin Ver 8.40 Distrib 4.0.16, for sun-solaris2.8 on sparc

I am trying to kill a query, been jammed to state: 'Repair with keycache' and command 'Killed' for 15655 seconds now and still counting.

I dont care if that table crash and have to fix it, but I want to kill that query no matter what I cannot shut down the whole mysql process or i'll have to fix hundreds of other tables.

Does anyone know how to do that ?

Posted by Cahyono Wisu on December 29 2003 6:25pm[Delete] [Edit]

Here the sample script to kill automatic the mysql user. I used this and my mysql server keep alive and not hang again.

$result = mysql_query("SHOW FULL PROCESSLIST");
while ($row=mysql_fetch_array($result)) {
$process_id=$row["Id"];
if ($row["Time"] > 200 ) {
$sql="KILL $process_id";
mysql_query($sql);
}
}

Add your own comment.