Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Trigger only for a certain mysql user

I'm trying to find out if a specific MySQL User is still in use in our system (and what queries it is executing).

So I thought of writing a trigger that would kick in anytime user X executes a query, and it would log the query in a log table.

How can I do that? I know how to write a query for a specific table, but not for a specific user (any table).

Thanks

like image 345
Nathan H Avatar asked Feb 08 '10 18:02

Nathan H


2 Answers

You could branch your trigger function on USER().

like image 134
cmptrgeekken Avatar answered Oct 27 '22 18:10

cmptrgeekken


The easiest would be to have the trigger always fire, but only logs if the user is X.

like image 31
RiddlerDev Avatar answered Oct 27 '22 20:10

RiddlerDev