Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do i view the last run queries in mysql in a live feed format?

I want to leave my terminal window open and just have mysql queries pop up on the screen whenever something is run. I know I can do it with the tail command, but im not sure where the mysql logs are stored. i can also do mysqladmin proc, but that doesnt give me a continuous live feed.

share|improve this question
    
Answered before here : stackoverflow.com/questions/650238/… –  schaiba Apr 26 '13 at 19:22
add comment

2 Answers

up vote 3 down vote accepted

You have a couple of options here. You can enable general query logging for MySQL, by adding:

 log = /path/to/your/log.log

to your my.cnf (typically /etc/my.cnf) and restarting. You can then tail it as needed. I wouldn't necessarily recommend this, as that log can grow quite large over time.

Your second option, as you had mentioned is to use watch in conjunction with mysqladmin proc. For example, you can use:

 watch -n.5 'mysqladmin proc stat'

to show you the process list and status every half second. You can change -n.5 to suit your specific needs (I prefer adding stat to the line to give the extra information, which can sometimes be helpful).

Hope this helps.

share|improve this answer
add comment

All queries are written to a file on the system called ".mysqlhistory". You can run the below command to actively view the queries being ran on your DB.

find / -name ".mysqlhistory" -exec 'tail -f'

share|improve this answer
add comment

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.