---
name: "mysql_thread_id"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_thread_id"
---

# mysql\_thread\_id(3)

### Name

mysql\_thread\_id - Returns id of the current connection

### Synopsis

-

  ```
  #include <mysql.h>
  unsigned long mysql_thread_id(MYSQL * mysql);
  ```

### Description

The mysql\_thread\_id() function returns the thread id for the current connection.

### Parameter

- •

  `mysql` - a mysql handle, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**. ### Notes

- •

  The current connection can be killed with **[mysql\_kill(3)](/mysql_kill/3.md)**.

- •

  If reconnect option is enabled the thread id might change if the client reconnects to the server.

### Return value

Returns the thread id of the current connection.

### See also

- •

  **[mysql\_kill(3)](/mysql_kill/3.md)**

- •

  **[mysql\_options(3)](/mysql_options/3.md)**
