> 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_thread_id.md).

# mysql\_thread\_id

## Syntax

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

## Parameter

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

## 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()](/docs/connectors/mariadb-connector-c/api-functions/mysql_kill.md). If reconnect option is enabled the thread id might change if the client reconnects to the server.
{% endhint %}

## See Also

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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_thread_id.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.
