Your post got me thinking.... I've been having problems with the search query for this forum being too slow and timing out Apache, so I decided to log long queries to find out what was going on...
In my my.cnf file, I added the following lines (forget about my last post with the set-variable as that is no longer needed in mysql after version 3)...
log_slow_queries=/var/log/slow-queries.log long_query_time=5
I restarted mysql and did a search and it timed out as usual, but nothing was logged and no log file was created. I assumed the mysql daemon would create the file /var/log/slow-queries.log but when I checked my mysql log by doing this...
tail -f /var/log/mysqld.log
I noticed the following error
071214 22:54:56 mysqld started /usr/sbin/mysqld: File '/var/log/slow-queries.log' not found (Errcode: 13) 071214 22:54:56 [ERROR] Could not use /var/log/slow-queries.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
OK, so mysql daemon *will not* create the log for you automatically like Apache does, so what you have to do is create the log, set permissions and owner like this...
touch /var/log/slow-queries.log chmod 660 /var/log/slow-queries.log chown mysql:root /var/log/slow-queries.log
The restart mysql and you will be able to get your long query log working fine !!!
|