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.

In order to debug a webapp and mysql queries, I've enabled the mysql query log. However it's not a very good format to tail and grep through. Ideally I'd like to be able to only show queries from a certain user, or queries to a certain database. If the mysql query log printed the database or user on each line, then I could grep it. Sometimes I want to see what happened at a certain date, but since mysql query log doesn't print the datetime on each line, then this is harder.

Is there some way to make the mysql query log be nicer to tail/grep/etc through?

share|improve this question
1  
Hey! Watch your language! ;-) Put a dollar in the jar. –  Dennis Williamson Jan 20 '10 at 16:52

2 Answers 2

You should probably use mk-query-digest - it's insanely powerful.

http://www.maatkit.org/doc/mk-query-digest.html

share|improve this answer

What you are trying to do, log queries for a single user, might be easier to accomplish through the mysql proxy. Basically it is a service that can sit between the mysql server and client(s). There are many code samples about how to log or manipulate data based on criteria you set.

Anyway I am not aware of any tools to do this. What you might need to do is find a mysql log parser library and write a script that uses the library and extracts the data you want.

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.