---
name: "mysql_kill"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_kill"
---

# mysql\_kill(3)

### Name

mysql\_kill - Kills a connection

### Synopsis

-

  ```
  #include <mysql.h>
  int mysql_kill(MYSQL * mysql,
                 unsigned long);
  ```

### Description

This function is used to ask the server to kill a MariaDB thread specified by the processid parameter. This value must be retrieved by \[show-processlist()\](SHOW PROCESSLIST\]\]. If trying to kill the own connection **[mysql\_thread\_id(3)](/mysql_thread_id/3.md)** should be used.

### Parameter

- •

  `mysql` - a connection identifier, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**. Returns 0 on success, otherwise nonzero.

- •

  `long` - process id

### Notes

- •

  To stop a running command without killing the connection use `KILL QUERY`.

- •

  The `mysql_kill()` function only kills a connection, it doesn’t free any memory - this must be done explicitly by calling **[mysql\_close(3)](/mysql_close/3.md)**.

### Return value

Returns zero on success, non zero on error.

### See also

- •

  **[mysql\_thread\_id(3)](/mysql_thread_id/3.md)**

- •

  **[mysql\_close(3)](/mysql_close/3.md)**

- •

  **[mariadb\_cancel(3)](/mariadb_cancel/3.md)**
