3

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?

4 Answers 4

2

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

3
  • 1
    why you are using chown recursive on a file? Commented Sep 4, 2013 at 21:34
  • @c4f4t0r muscle reflex Commented Sep 4, 2013 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. Commented Sep 5, 2013 at 12:43
0

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); 
0

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

0

Note that, in Centos 7, as default and without a MySQL restart, the slow query log is enabled in this position:

/var/lib/mysql/$HOSTNAME.log 

See the other answers to discover how to apply your persistent configuration and how to move it to another position.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.