# mysql\_kill

## Syntax

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

* `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).
* `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.

Returns 0 on success, otherwise 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" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_kill.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
