Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been looking at logging only certain users activity in MySQL. I found that the logging could be enabled or disabled for all users but one of the service using the db does a lot of queries and therefore I would like to only log specific users.

Google told me that a flag can be SET to enable disable logging, however, I cannot modify the service DB connection code and asking every single user to enable logging before they do anything might not be as reliable as I want.

So, do you know if there is any way to log only a set of users queries ?

Thanks !

share|improve this question
1  
MySQL does not have this functionality natively. –  longneck Sep 26 '12 at 3:15

3 Answers 3

up vote 1 down vote accepted

Install mySQL proxy and do your logging there.

share|improve this answer
    
Perfect, thanks :) works like a charm –  Adraen Sep 26 '12 at 13:40

newer versions of mysql support logging to tables. this could be abused in interesting ways:

  • write a trigger to delete rows from the logging table that do not correspond to the users you are interested in monitoring.
  • partition the logging table on username. periodically empty the partitions for the users you are not interested in monitoring.
share|improve this answer
    
Thanks for the reply, however, the main reason not to log the service is to prevent massive performance drop, if I do it the way you suggest I will still have the performance penalty. –  Adraen Sep 26 '12 at 0:42

You could enable logging globally, then alter the connection code to disable logging for the high load users that you don't want to monitor. I can think of a couple of cases in my environment where this would be most efficient, so it might work for you, too.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.