Wednesday, March 5, 2008

How to Log Slow MySQL Queries

Create a log that shows slow MySQL queries

This process will create a log file that will show you any queries taking longer than normal. Read the steps, then copy and paste the commands one at a time.

1) Create the folder /home/mysqllogs. Chown it to mysql:mysql

mkdir /home/mysqllogs
chown mysql:mysql /home/mysqllogs

2) Edit the /etc/my.cnf file.

nano /etc/my.cnf

* Add the following line under the [mysqld] header:

log-slow-queries = /home/mysqllogs/slow_queries.log

3) Restart MySQL? services

service mysql stop
service mysql start

No comments: