{"id":14343,"date":"2024-01-06T19:18:09","date_gmt":"2024-01-07T02:18:09","guid":{"rendered":"https:\/\/www.mysqltutorial.org\/?page_id=14343"},"modified":"2024-01-06T20:05:48","modified_gmt":"2024-01-07T03:05:48","slug":"kill-process-in-mysql","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/","title":{"rendered":"How to Kill a Process in MySQL"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via the mysql client tool and <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysqladmin\/\">mysqladmin<\/a>.<\/p>\n\n\n\n<p>MySQL creates a thread for each connection to the mysqld server. You can kill a thread (or process) with the <code>KILL<\/code> statement.<\/p>\n\n\n\n<p class=\"note\">Notice that we&#8217;ll use the terms process and thread interchangeably but they are different from the technical point of view<\/p>\n\n\n\n<p>First, find the thread <code>ID<\/code> using the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysql-show-processlist\/\">SHOW PROCESSLIST<\/a> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SHOW<\/span> <span class=\"hljs-keyword\">PROCESSLIST<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This statement returns a list of running processes, each is assigned an id.<\/p>\n\n\n\n<p>Second, kill a thread by its <code>ID<\/code> using the <code>KILL<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">KILL<\/span> <span class=\"hljs-keyword\">id<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To run the <code>KILL<\/code> command, you need to have the <code>CONNECTION_ADMIN<\/code> privilege.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Kill a process using mysql client<\/h2>\n\n\n\n<p>First, open the Command Prompt on Windows or Terminal on Unix-like systems.<\/p>\n\n\n\n<p>Second, <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/connect-to-mysql-server\/\">connect to the MySQL server<\/a> using the mysql client tool:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">mysql -u root -p<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, display all processes in the server using the <code>SHOW<\/code> <code>PROCESSLIST<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SHOW<\/span> <span class=\"hljs-keyword\">PROCESSLIST<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;ll display the currently running threads:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">+<span class=\"hljs-comment\">----+-----------------+-----------------+------+---------+--------+------------------------+------------------+<\/span>\n| Id | User            | Host            | db   | Command | Time   | State                  | Info             |\n+<span class=\"hljs-comment\">----+-----------------+-----------------+------+---------+--------+------------------------+------------------+<\/span>\n|  5 | event_scheduler | localhost       | NULL | Daemon  | 134298 | Waiting on empty queue | NULL             |\n| 50 | root            | localhost:63998 | NULL | Query   |      0 | init                   | <span class=\"hljs-keyword\">show<\/span> <span class=\"hljs-keyword\">processlist<\/span> |\n| <span class=\"hljs-number\">52<\/span> | bob             | localhost:<span class=\"hljs-number\">64014<\/span> | <span class=\"hljs-literal\">NULL<\/span> | <span class=\"hljs-keyword\">Sleep<\/span>   |      <span class=\"hljs-number\">6<\/span> |                        | <span class=\"hljs-literal\">NULL<\/span>             |\n+<span class=\"hljs-comment\">----+-----------------+-----------------+------+---------+--------+------------------------+------------------+<\/span>\n<span class=\"hljs-number\">3<\/span> <span class=\"hljs-keyword\">rows<\/span> <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (<span class=\"hljs-number\">0.00<\/span> sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, the output shows that the local MySQL server has three threads. To kill a thread, you need to find the <code>ID<\/code> of the process and execute the <code>KILL<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">KILL<\/span> <span class=\"hljs-keyword\">id<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, you can kill the process with <code>ID<\/code> 52 as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">KILL<\/span> <span class=\"hljs-number\">52<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you use the <code>bob<\/code> user account to make a query, you&#8217;ll see the following message:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">ERROR 2013 (HY000): Lost connection to MySQL server during query\nNo connection. Trying to reconnect...\nConnection id:    54\nCurrent database: *** NONE ***<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The message says that the session of <code>bob<\/code> was lost and reconnected immediately.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Kill a process using the mysqladmin tool<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysqladmin\/\">mysqladmin<\/a> is a client tool that allows you to perform database administrative tasks. To kill a process using mysqladmin, you follow these steps:<\/p>\n\n\n\n<p>First, show the processes using the <code>mysqladmin processlist<\/code> command:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">mysqladmin -u root -p processlist;<\/code><\/span><\/pre>\n\n\n<p>It&#8217;ll display a list of processes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">+----+-----------------+-----------------+----+---------+--------+------------------------+------------------+\r\n| Id | User            | Host            | db | Command | Time   | State                  | Info             |\r\n+----+-----------------+-----------------+----+---------+--------+------------------------+------------------+\r\n| <span class=\"hljs-number\">5<\/span>  | event_scheduler | localhost       |    | Daemon  | <span class=\"hljs-number\">140572<\/span> | Waiting on <span class=\"hljs-keyword\">empty<\/span> queue |                  |\r\n| <span class=\"hljs-number\">53<\/span> | root            | localhost:<span class=\"hljs-number\">64026<\/span> |    | Sleep   | <span class=\"hljs-number\">5589<\/span>   |                        |                  |\r\n| <span class=\"hljs-number\">54<\/span> | bob             | localhost:<span class=\"hljs-number\">64051<\/span> |    | Sleep   | <span class=\"hljs-number\">6065<\/span>   |                        |                  |\r\n| <span class=\"hljs-number\">56<\/span> | root            | localhost:<span class=\"hljs-number\">50039<\/span> |    | Query   | <span class=\"hljs-number\">0<\/span>      | init                   | show processlist |\r\n+----+-----------------+-----------------+----+---------+--------+------------------------+------------------+<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, kill a process by id using the kill command. For example:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">mysqladmin -u root -p kill 54<\/code><\/span><\/pre>\n\n\n<p>Behind the scenes, the mysqladmin kill command executes the <code>KILL<\/code> statement to kill a process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Kill all processes in MySQL<\/h2>\n\n\n\n<p>MySQL does not have a statement that kills all processes or processes that belong to a user once. To do that you need to do a little bit more work.<\/p>\n\n\n\n<p>MySQL stores the process list in the <code>information_schema.processlist<\/code> table. Therefore, you can retrieve the current process list with id from the information_schema.processlist table.<\/p>\n\n\n\n<p>Here is the <code>processlist<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">DESC<\/span> <span class=\"hljs-selector-tag\">information_schema<\/span><span class=\"hljs-selector-class\">.processlist<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">+---------+-----------------+------+-----+---------+-------+\r\n| Field   | Type            | <span class=\"hljs-keyword\">Null<\/span> | Key | <span class=\"hljs-keyword\">Default<\/span> | Extra |\r\n+---------+-----------------+------+-----+---------+-------+\r\n| ID      | bigint unsigned | NO   |     |         |       |\r\n| USER    | varchar(<span class=\"hljs-number\">32<\/span>)     | NO   |     |         |       |\r\n| HOST    | varchar(<span class=\"hljs-number\">261<\/span>)    | NO   |     |         |       |\r\n| DB      | varchar(<span class=\"hljs-number\">64<\/span>)     | YES  |     |         |       |\r\n| COMMAND | varchar(<span class=\"hljs-number\">16<\/span>)     | NO   |     |         |       |\r\n| TIME    | int             | NO   |     |         |       |\r\n| STATE   | varchar(<span class=\"hljs-number\">64<\/span>)     | YES  |     |         |       |\r\n| INFO    | varchar(<span class=\"hljs-number\">65535<\/span>)  | YES  |     |         |       |\r\n+---------+-----------------+------+-----+---------+-------+\r\n<span class=\"hljs-number\">8<\/span> rows in set (<span class=\"hljs-number\">0.04<\/span> sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>First, construct a list of <code>KILL<\/code> statements that kill the processes belonging to user account <code>bob<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SELECT CONCAT(<span class=\"hljs-string\">'KILL '<\/span>,id, <span class=\"hljs-string\">';'<\/span>) \nFROM information_schema.processlist \nWHERE user=<span class=\"hljs-string\">'bob'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+-------------------------+\r\n| CONCAT(<span class=\"hljs-string\">'KILL '<\/span>,id, <span class=\"hljs-string\">';'<\/span>) |\r\n+-------------------------+\r\n| KILL <span class=\"hljs-number\">59<\/span>;                |\r\n| KILL <span class=\"hljs-number\">61<\/span>;                |\r\n+-------------------------+\r\n<span class=\"hljs-number\">2<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, find the location on the MySQL server where you can store a file securely:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">SELECT<\/span> @<span class=\"hljs-keyword\">@secure_file_priv<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;ll show something like the following on Windows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+------------------------------------------------+\r\n| @@secure_file_priv                             |\r\n+------------------------------------------------+\r\n| C:\\ProgramData\\MySQL\\MySQL Server <span class=\"hljs-number\">8.0<\/span>\\Uploads\\ |\r\n+------------------------------------------------+\r\n<span class=\"hljs-number\">1<\/span> row <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>You need to construct the file name in the secure file directory such as:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">C:<span class=\"hljs-regexp\">\/ProgramData\/<\/span>MySQL\/MySQL Server <span class=\"hljs-number\">8.0<\/span>\/Uploads\/kill.txt<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Note that on Windows, you need to replace the backslash (\\) with the forward (\/) in the file path.<\/p>\n\n\n\n<p>Third, save the <code>KILL<\/code> statements into a file on the MySQL:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SELECT CONCAT(<span class=\"hljs-string\">'KILL '<\/span>,id, <span class=\"hljs-string\">';'<\/span>) \nFROM information_schema.processlist \nWHERE user=<span class=\"hljs-string\">'bob'<\/span>\nINTO OUTFILE <span class=\"hljs-string\">'C:\/ProgramData\/MySQL\/MySQL Server 8.0\/Uploads\/kill.txt'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">Query<\/span> <span class=\"hljs-selector-tag\">OK<\/span>, 2 <span class=\"hljs-selector-tag\">rows<\/span> <span class=\"hljs-selector-tag\">affected<\/span> (0<span class=\"hljs-selector-class\">.01<\/span> <span class=\"hljs-selector-tag\">sec<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>kill.txt<\/code> file will contain the following lines:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">KILL 59;\nKILL 61;<\/code><\/span><\/pre>\n\n\n<p>Finally, execute the <code>KILL<\/code> statements in the <code>kill.txt<\/code> file to kill the processes that belong to the user account bob:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SOURCE C:<span class=\"hljs-regexp\">\/ProgramData\/<\/span>MySQL\/MySQL Server <span class=\"hljs-number\">8.0<\/span>\/Uploads\/kill.txt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/execute-sql-file-in-mysql\/\">SOURCE<\/a> statement executes all SQL statements in the kill.txt file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>SHOW<\/code> <code>PROCESSLIST<\/code> statement to display a list of threads and  the <code>KILL<\/code> statement to kill a thread by an id.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"14343\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/\"\n\t\t\t\tdata-post-title=\"How to Kill a Process in MySQL\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"14343\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/\"\n\t\t\t\tdata-post-title=\"How to Kill a Process in MySQL\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to kill a process in MySQL using the KILL statement.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":441,"menu_order":64,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-14343","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Kill a Process in MySQL<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Kill a Process in MySQL\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-07T03:05:48+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/kill-process-in-mysql\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/kill-process-in-mysql\\\/\",\"name\":\"How to Kill a Process in MySQL\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"datePublished\":\"2024-01-07T02:18:09+00:00\",\"dateModified\":\"2024-01-07T03:05:48+00:00\",\"description\":\"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/kill-process-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/kill-process-in-mysql\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/kill-process-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Administration\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Kill a Process in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Kill a Process in MySQL","description":"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Kill a Process in MySQL","og_description":"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-07T03:05:48+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/","url":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/","name":"How to Kill a Process in MySQL","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"datePublished":"2024-01-07T02:18:09+00:00","dateModified":"2024-01-07T03:05:48+00:00","description":"In this tutorial, you will learn how to kill a process in MySQL using the KILL statement via mysql client tool and mysqladmin.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-administration\/kill-process-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Administration","item":"https:\/\/www.mysqltutorial.org\/mysql-administration\/"},{"@type":"ListItem","position":3,"name":"How to Kill a Process in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/14343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=14343"}],"version-history":[{"count":4,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/14343\/revisions"}],"predecessor-version":[{"id":14353,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/14343\/revisions\/14353"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/441"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=14343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}