1 线程结构
1.1 前台线程(连接层)
show processlist ; show full processlist; ##查看有那些用户正在连接数据库
select from information_schema.processlist ; ##查看有那些用户正在连接数据库
1.2 后台线程(Server\Engine)
mysql> select from performance_schema.threads\G
说明: 如何查询到连接线程和SQL线程关系
select from information_schema.processlist ; —-> ID=10 这个id号对应后台线程的id号
select from performance_schema.threads where processlist_id=10\G ##对应前台的ID号
查看后台的id跟前台关联的id可以判断出这个线程在执行什么sql为什么会卡住,可不可以进行kill。THRED_os_ID=43169 这个是对应系统的线程ID号可以使用 top -Hp mysqld线程ID,使用ps -axu | grep mysqld查询,在使用top -Hp 加上线程ID,找到PID等于 43169这个线程
select * from performance_schema.events_statements_history where thread_id=?
performance_schema.events_statements_history : 在这个表中可以帮我们记录某些线程执行了那些sql语句也是通过,thread_id去查看。
