Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] MySQL - What is my thread or connection ID?
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2880
Topic starter
August 19, 2013 7:35 AM
Sometimes a query can go haywire, often I do recognize which of the connections/processes is mine based on the SQL statement that is running, but sometimes it can be hard for example when my query triggers a trigger - in which case the SQL might not match my original query. In those cases I need the connection ID. With a simple SQL statement this can be retrieved:
CONNECTION_ID()
The returns the connection ID (thread ID) for the connection. Every connection has an ID that is unique among the set of currently connected clients.
mysql> SELECT CONNECTION_ID();
-> 23786