> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_kill.md).

# mysql\_kill

## Syntax

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

## Parameters

* `mysql` - a mysql handle, which was previously allocated by [mysql\_init()](/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md) or [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md).
* `unsigned 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](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-processlist.md). If trying to kill the own connection [mysql\_thread\_id()](/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_id.md) should be used.

## Return Value

Returns 0 on success, otherwise error on nonzero.

{% hint style="info" %}

* To stop a running command without killing the connection, use [KILL QUERY](/docs/server/reference/sql-statements/administrative-sql-statements/kill.md).
* The `mysql_kill()` function only kills a connection; it doesn't free any memory - this must be done explicitly by calling [mysql\_close()](/docs/connectors/mariadb-connector-c/api-functions/mysql_close.md).
  {% endhint %}

## See Also

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

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