Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
MySQL does not have this functionality natively. – longneck Sep 26 '12 at 3:15
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


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.