MySQL Shutdown and kill

Source: Internet
Author: User
Tags modifier terminates

--mysqladmin shutdown

If you execute mysqladmin shutdown while connecting to a local server using a Unix socket file, mysqladminwaits until the server's process ID file has a been removed, to ensure that the server has stopped properly.

KILL Syntax

thread_id

Each connection to Mysqld runs in a separate thread. You can see which threads is running with the SHOW PROCESSLIST statement and kill a thread with the KILL thread_id statement.

KILLPermits an optional CONNECTION or QUERY modifier:

    • KILL CONNECTIONIs the same as with KILL no modifier:it terminates the connection associated with the given thread_id .

    • KILL QUERYTerminates the statement, the connection is currently executing, but leaves the connection itself intact.

If you had PROCESS the privilege, you can see all threads. If you had SUPER the privilege, you can kill all threads and statements. Otherwise, you can see and kill only your own threads and statements.

You can also with the mysqladmin processlist and mysqladmin kill commands to examine and kill threads.

Note

You cannot use with the KILL Embedded MySQL Server Library because the Embedded Server merely runs the inside of The host application. It does not create any connection threads of its own.

When you use KILL , a thread-specific kill flag was set for the thread. In most cases, it might take some time for the thread of the die because the kill flag was checked only at specific intervals:

  • In SELECT , ORDER BY and GROUP BY loops, the flag was checked after reading a block of rows. If the KILL flag is set, the statement is aborted.

  • During ALTER TABLE , the kill flag is checked before each block of rows was read from the original table. If the KILL flag was set, the statement are aborted and the temporary table is deleted.

  • During UPDATE or DELETE 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. Note that if you is not using transactions, the changes is not rolled back.

  • GET_LOCK()Aborts and returns NULL .

  • An INSERT DELAYED thread quickly flushes (inserts) All rows it have in memory and then terminates.

  • 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 was aborted with a "disk full" error MESSAG E.

  • Warning

    Killing a REPAIR TABLE or OPTIMIZE TABLE operation on a MyISAM table results in a table it is corrupted and unusable. Any reads or writes to such a table fail until you optimize or repair it again (without interruption).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.