# mysql\_kill

## Syntax

```c
int mysql_kill(MYSQL * mysql,
               unsigned long);
```

* `mysql` - a mysql handle, which was previously allocated by [mysql\_init()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_init) or [mysql\_real\_connect()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect).
* `long` - process id

## 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](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/sql-statements/administrative-sql-statements/show/show-processlist). If trying to kill the own connection [mysql\_thread\_id()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_id) should be used.

Returns 0 on success, otherwise nonzero.

{% hint style="info" %}
To stop a running command without killing the connection, use [KILL QUERY](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/sql-statements-and-structure/sql-statements/administrative-sql-statements/kill). The `mysql_kill()` function only kills a connection; it doesn't free any memory - this must be done explicitly by calling [mysql\_close()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_close).
{% endhint %}

## See also

* [mysql\_thread\_id()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_id)
* [mysql\_close()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_close)
* [mariadb\_cancel()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mariadb_cancel)

{% @marketo/form formId="4316" %}
