Can you give me an example on how to enable MySQL's slow query log?
According to the doc:
As of MySQL 5.1.29, use --slow_query_log[={0|1}] to enable or disable the slow query log, and optionally --slow_query_log_file=file_name to specify a log file name. The --log-slow-queries option is deprecated.
So how do I use that option? Can I put it in my.cnf
? An example would be greatly appreciated.
Correct.
It's best to put this in the general/global (top) part of your my.cnf file.
There are two things you need to do : (1) enable it, and (2) define the logfile destination.
Hope this helps.
Here is something interesting.
MySQL 5.1/5.5 allows you to convert the slow query log to MyISAM.
Here is how I do it for my clients:
Step 1) Add these line to /etc/my.cnf
Step 2) Restart mysql (service mysql restart)
At this point, the table mysql.slow_log exists but as storage engine CSV.
Step 3) Convert mysql.slow_log to MyISAM and Index the start_time field
Now you can run SELECT queries against it.
Give it a Try.