Mysql – How to enable the MySQL Slow query log (5.5.15)

MySQL

Need some help. I've looked around topics here on stack and on mysql's website and none of the configurations ever work for me. I need to enable the MySQL slow query log as well as teh general query log. I want to do it in my config file rather than as a SET statement because I assume that would reset whenever mysql was rebooted?

What am I missing?! Every site says something completely different… I'm using MySQL 5.5.15. This is my current config:

[mysqld]
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
skip-external-locking

query_cache_limit=8M
query_cache_size=64M
query_cache_type=1

long_query_time=2
slow_query_log_file=/var/log/mysqld.slow.log

max_connections=100
max_user_connections=10
interactive_timeout=20
wait_timeout=20
connect_timeout=6

thread_cache_size=128
key_buffer=16M
key_buffer_size=256M

join_buffer=1M
max_allowed_packet=16M
table_cache=1024
read_buffer_size=2M
sort_buffer_size=2M
max_connect_errors=10

# Try number of CPU's*2 for thread_concurrency
thread_concurrency=4
myisam_sort_buffer_size=64M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Best Answer

Add slow_query_log=1 to your config file.

Reference

Related Topic