My MySQL server has been unusually been using a higher load of CPU. So I looked around how to log each queries and I found a lot of tutorials that were saying the same thing: http://www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/
I followed the tutorial but the log file did not contain any queries. One thing I thought I should mention is that, the /var/logs/
the folder mysql
did not exist, so I made the folder and created a log file called mysql.log
in it.
A little background of my box:
- Arch Linux
- Nginx
- PHP/Ruby/Python/Perl
- MySQL
By default mysql keep logs in the working directory, usually /var/db/mysql. All you need to enable logging is to set variable
general_log
to "ON". Also, you can setgeneral_log_file
variable to the desired place.Check out the Slow Query Log option.
You can find detailed information on dev.mysql.com