Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - show query by query id in mysql < 5.1.7

Tags:

mysql

I have a long running transaction running on a database

---TRANSACTION 2 4166167596, ACTIVE 14868 sec, process no 7906, OS thread id 1169635648
MySQL thread id 34318076, query id 1997556522 10.186.131.136 admin

The above is an output from SHOW INNODB ENGINE STATUS command

I want to see what query is running by with the query id 1997556522. SHOW FULL PROCESSLIST is not an option, since it requires me to manually find the query from a list of hundreds.

This SO Thread says you can do that by querying the INFORMATION_SCHEMA.PROCESSLIST table on MySQL 5.1.7 and greater. Is it possible to do so on an older version?

I am running on MySQL 5.0.45

like image 667
rubayeet Avatar asked Jan 07 '14 13:01

rubayeet


People also ask

What is show Processlist MySQL?

SHOW [FULL] PROCESSLIST. The MySQL process list indicates the operations currently being performed by the set of threads executing within the server. The SHOW PROCESSLIST statement is one source of process information. For a comparison of this statement with other sources, see Sources of Process Information.

How do I find MySQL process ID?

Login to DB; Run a command show full processlist; to get the process id with status and query itself which causes the database hanging; Select the process id and run a command KILL <pid>; to kill that process.


1 Answers

You should use the thread id, not the query id.

If you have shell access you can execute show full processlist and then grep for the relevant thread id.

For example:

mysql -e "show full processlist;" | grep 34318076
like image 168
Ike Walker Avatar answered Sep 21 '22 23:09

Ike Walker