[MySQL] Get the current connection ID

Created on November 30, 2026

You can call CONNECTION_ID() to get the numeric ID of the current MySQL connection.

SELECT CONNECTION_ID();

The value depends on the connection. For example:

+-----------------+
| CONNECTION_ID() |
+-----------------+
|              10 |
+-----------------+
MySQL