Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I was looking today on my CentOS server for a MySQL Slow Queries Log, but have had no luck finding the log. I even did a "SELECT SLEEP(2)" test in hopes to have this file created. Take note, I am not very server savvy so any help is appreciated.

 7
  8 [mysql.server]
  9 user=mysql
 10 basedir=/var/lib
 11
 12 [mysqld]
 13 long_query_time = 1
 14 log_slow_queries=/var/log/mysql_slow_queries.log
 15 log=/var/log/mysql.query.log
 16
 17 ## FINE TUNING ##
 18
 19 key_buffer              = 16M
 20 max_allowed_packet      = 16M
 21 thread_stack            = 128K
 22 thread_cache_size       = 8
 23 query_cache_limit       = 1M
 24 query_cache_size        = 16M
 25
 26 [mysqld_safe]
 27 log-error=/var/log/mysqld.log
 28 pid-file=/var/run/mysqld/mysqld.pid
 29 safe-show-databases

As you can see the path shows: /var/log/mysql_slow_queries.log -- but this file is no where to be found. I have found mysql.query.log and mysqld.log just fine in the directory however. Why does my MySQL Slow Queries file not exist?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Once you have made the changes to your my.cnf file, you need to restart the MySQL service. Not sure what system you are on, but typically service mysqld restart will work or service mysql restart -- just look in /etc/init.d/

In addition, make sure the file is created and available on disk:

touch /var/log/mysql_slow_queries.log

chown -R mysql:mysql /var/log/mysql_slow_queries.log

In addition, time is not so important in databases but rather queries with no indices. Consider adding the following to your my.cnf. Of course, restart MySQL once you do:

log-queries-not-using-indexes

share|improve this answer
    
why you are using chown recursive on a file? –  c4f4t0r Sep 4 '13 at 21:34
    
@c4f4t0r muscle reflex –  Adam Sep 4 '13 at 21:37
    
Thank you both for your help. I wish I could have chosen both answers as the selected answer, because both were helpful. I greatly appreciate the help; both answers worked out great. –  Ryan Sep 5 '13 at 12:43

touch /var/log/mysql_slow_queries.log

chown mysql:mysql

and restart your mysql service

mysql -u -pmypassword

select sleep(60);

cat /var/log/mysql_slow_queries.log

/usr/sbin/mysqld, Version: 5.5.28-log (Source distribution). started with:
Tcp port: 3306  Unix socket: /var/run/mysql/mysql.sock
Time                 Id Command    Argument
# Time: 130904 23:22:14
# User@Host: root[root] @ localhost []
# Query_time: 60.002284  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1378329734;
select sleep(60);
share|improve this answer

add slow_query_log=1 to the [mysqld] section of my.cnf and restart mysqld.

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.