Centos – Why does MySQL Slow Queries Log not exist

centosloggingMySQL

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?

Best Answer

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 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

Related Topic