Answer the question
In order to leave comments, you need to log in
How to catch a specific query in MySql?
Hello colleagues!
Please advise how to solve the following problem.
There are many servers and a large database with tables. There is an insert into a certain table and it is impossible to catch from which ip the request is being made. The looped bash script used with the query did not return any results:
#!/bin/bash
c=1
while [ "$c" ]
do
sleep 6
mysql -e "show processlist;" | grep 'insert into nametable' >> nametable.log
done
Answer the question
In order to leave comments, you need to log in
Make a trigger on the table on, for example, BEFORE INSERT, write data to another table, the address of the host that launched the query can be found like this:
SELECT substring_index(host,':',1) ip
FROM information_schema.processlist
WHERE id = connection_id();
2 options.
1. mytop (similar to show full processlist;)
If the request is processed very quickly, you can include before the request:
mysql -p
SET global general_log = 1;
###выполняем запрос###
SET global general_log = 0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question