获取mysql进程id

ps -ef | grep -i mysql

实时查看mysql进程中占用CPU,内存最多的操作系统线程ID
top -p 2296-H

  1.  
    top -p 2296 -H
  2.  
    select thread_id,name ,PROCESSLIST_ID,THREAD_OS_ID from threads where thread_os_id = 2966 ;
  3. 根据mysql数据库的线程ID获取sql
select sql_text from performance_schema.events_statements_current where thread_id = 78 \G;

       使用MySQL内部的表定位问题SQL。
SELECT a.THREAD_OS_ID,b.user,b.host,b.db,b.command,b.time,b.state,b.info
FROM performance_schema.threads a,information_schema.processlist b
WHERE b.id = a.processlist_id;
THREAD_OS_ID USER HOST db command TIME state info