1、获取mysql进程id
ps -ef | grep -i mysql
2、实时查看mysql进程中占用CPU,内存最多的操作系统线程ID
top -p 2296 -H
3、根据操作系统线程ID,查看mysql数据库中对应的线程ID
select thread_id,name ,PROCESSLIST_ID,THREAD_OS_ID from `performance_schema`.threads where thread_os_id = 2966;
4、根据mysql数据库的线程ID获取sql
select sql_text from performance_schema.events_statements_current where thread_id = 78 \G