Rechercher dans le manuel MySQL
13.7.7.4 KILL Syntax
Each connection to mysqld runs in a separate
thread. You can kill a thread with the KILL
statement.
processlist_id
Thread processlist identifiers can be determined from the
ID
column of the
INFORMATION_SCHEMA
PROCESSLIST
table, the
Id
column of SHOW
PROCESSLIST
output, and the
PROCESSLIST_ID
column of the Performance
Schema threads
table. The value for
the current thread is returned by the
CONNECTION_ID()
function.
KILL
permits an optional
CONNECTION
or QUERY
modifier:
KILL CONNECTION
is the same asKILL
with no modifier: It terminates the connection associated with the givenprocesslist_id
, after terminating any statement the connection is executing.KILL QUERY
terminates the statement the connection is currently executing, but leaves the connection itself intact.
If you have the PROCESS
privilege, you can see all threads. If you have the
CONNECTION_ADMIN
or
SUPER
privilege, you can kill all
threads and statements. Otherwise, you can see and kill only
your own threads and statements.
You can also use the mysqladmin processlist and mysqladmin kill commands to examine and kill threads.
When you use KILL
, a
thread-specific kill flag is set for the thread. In most cases,
it might take some time for the thread to die because the kill
flag is checked only at specific intervals:
During
SELECT
operations, forORDER BY
andGROUP BY
loops, the flag is checked after reading a block of rows. If the kill flag is set, the statement is aborted.ALTER TABLE
operations that make a table copy check the kill flag periodically for each few copied rows read from the original table. If the kill flag was set, the statement is aborted and the temporary table is deleted.The
KILL
statement returns without waiting for confirmation, but the kill flag check aborts the operation within a reasonably small amount of time. Aborting the operation to perform any necessary cleanup also takes some time.During
UPDATE
orDELETE
operations, the kill flag is checked after each block read and after each updated or deleted row. If the kill flag is set, the statement is aborted. If you are not using transactions, the changes are not rolled back.GET_LOCK()
aborts and returnsNULL
.If the thread is in the table lock handler (state:
Locked
), the table lock is quickly aborted.If the thread is waiting for free disk space in a write call, the write is aborted with a “disk full” error message.
Killing a REPAIR TABLE
or
OPTIMIZE TABLE
operation on a
MyISAM
table results in a table that is
corrupted and unusable. Any reads or writes to such a table
fail until you optimize or repair it again (without
interruption).
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-kill.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.