# mysql\_thread\_id

## Syntax

```c
unsigned long mysql_thread_id(MYSQL * mysql);
```

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

## Description

The `mysql_thread_id()` function returns the thread id for the current connection.

{% hint style="info" %}
The current connection can be killed with [mysql\_kill()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_kill). If reconnect option is enabled the thread id might change if the client reconnects to the server.
{% endhint %}

## See also

* [mysql\_kill()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_kill)
* [mysql\_options()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_options)

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