0

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
samwell
  • 339
  • 1
  • 6
  • 13
  • Well what do you have in your mysql config? Do you have an uncommetteded `log =`? – Zoredache Jul 09 '12 at 17:46
  • Setting logging via config needs to restart server to take effect. Otherwise, global variables take effect immediately. – Kondybas Jul 09 '12 at 17:53
  • Sorry, should have mentioned that. No originally I did not have an uncommented line for `log = `. So I did add in that part, this is what I put: `log = /var/log/mysql/mysql.log`. – samwell Jul 09 '12 at 17:56
  • @Kondybas, I did restart both MySQL and the whole server, and I still got the same results – samwell Jul 09 '12 at 17:57
  • recommendations to turn on the general log are not helpful for performance troubleshooting. Enable the slow query log instead as nojak suggests – Gavin Towey Jul 10 '12 at 02:32

2 Answers2

1

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 set general_log_file variable to the desired place.

SET @@global.general_log = 1;
SET @@global.general_log_file = '/where/to/store/log/file.txt';
Kondybas
  • 6,964
  • 2
  • 20
  • 24
1

Check out the Slow Query Log option.

You can find detailed information on dev.mysql.com

tacotuesday
  • 1,389
  • 1
  • 16
  • 27