数据库
首页 > 数据库> > mysql 获取连接id与线程id

mysql 获取连接id与线程id

作者:互联网

1.获取当前session的连接ID

mysql> select connection_id();
+-----------------+
| connection_id() |
+-----------------+
| 121 |
+-----------------+
1 row in set (0.00 sec)

2.获取当前session的线程id

mysql> select ps_current_thread_id();
+------------------------+
| ps_current_thread_id() |
+------------------------+
| 180 |
+------------------------+
1 row in set (0.00 sec)

 

一般情况下一个连接id对应一个线程id

 

标签:set,+-----------------+,线程,mysql,+------------------------+,id
来源: https://www.cnblogs.com/JennyYu/p/16215683.html