mysql+查看connection_如何查看MySQL connection id连接id

每个MySQL连接,都有一个连接ID,可以通过 connection_id()查看。

连接id也可以通过以下方式查看:

show processlist中id列

information_schema.processlist的id列

performance_schema.threads的processlist_id 列

下面通过具体命令查看连接id。

查看连接id:

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

| 15 |

+-----------------+

1 row in set (0.00 sec)

查看show processlist:

mysql> show processlist;

+----+------+-----------------+------+---------+------+----------+------------------+

| Id | User | Host | db | Command | Time | State | Info |

+----+------+-----------------+------+---------+------+----------+------------------+

| 3 | root | localhost:60989 | cmdb | Sleep | 318 | | NULL |

| 4 | root | localhost:60990 | cmdb | Sleep | 318 | | NULL |

| 15 | root | localhost | NULL | Query | 0 | starting | show processlist |

+----+------+-----------------+------+---------+------+----------+------------------+

3 rows in set (0.00 sec)

查看数据表information_schema.processlist:

mysql> select * from information_schema.processlist;

+----+------+-----------------+------+---------+------+-----------+-----------------------------------------------+

| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |

+----+------+-----------------+------+---------+------+-----------+-----------------------------------------------+

| 3 | root | localhost:60989 | cmdb | Sleep | 157 | | NULL |

| 15 | root | localhost | NULL | Query | 0 | executing | select * from INFORMATION_SCHEMA.PROCESSLIST |

| 4 | root | localhost:60990 | cmdb | Sleep | 157 | | NULL |

+----+------+-----------------+------+---------+------+-----------+-----------------------------------------------+

3 rows in set (0.00 sec)

查看数据表performance_schema.threads:

mysql> select thread_id, name, processlist_id from performance_schema.threads;

+-----------+----------------------------------------+----------------+

| thread_id | name | processlist_id |

+-----------+----------------------------------------+----------------+

| 1 | thread/sql/main | NULL |

| 2 | thread/sql/thread_timer_notifier | NULL |

| 3 | thread/innodb/io_ibuf_thread | NULL |

| 4 | thread/innodb/io_log_thread | NULL |

| 5 | thread/innodb/io_read_thread | NULL |

| 6 | thread/innodb/io_read_thread | NULL |

| 7 | thread/innodb/io_read_thread | NULL |

| 8 | thread/innodb/io_read_thread | NULL |

| 9 | thread/innodb/io_write_thread | NULL |

| 10 | thread/innodb/io_write_thread | NULL |

| 11 | thread/innodb/io_write_thread | NULL |

| 12 | thread/innodb/io_write_thread | NULL |

| 13 | thread/innodb/page_cleaner_thread | NULL |

| 16 | thread/innodb/srv_lock_timeout_thread | NULL |

| 15 | thread/innodb/srv_error_monitor_thread | NULL |

| 17 | thread/innodb/srv_monitor_thread | NULL |

| 18 | thread/innodb/srv_master_thread | NULL |

| 19 | thread/innodb/srv_worker_thread | NULL |

| 20 | thread/innodb/srv_worker_thread | NULL |

| 21 | thread/innodb/srv_purge_thread | NULL |

| 22 | thread/innodb/srv_worker_thread | NULL |

| 23 | thread/innodb/buf_dump_thread | NULL |

| 24 | thread/innodb/dict_stats_thread | NULL |

| 25 | thread/sql/signal_handler | NULL |

| 26 | thread/sql/compress_gtid_table | 1 |

| 28 | thread/sql/one_connection | 3 |

| 29 | thread/sql/one_connection | 4 |

| 40 | thread/sql/one_connection | 15 |

+-----------+----------------------------------------+----------------+

28 rows in set (0.00 sec)

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值