Enable slow
query log in MySQL
#
touch /var/log/mysql/mysql-slow.log
# chown
mysql:mysql /var/log/mysql/mysql-slow.logIf you want to leave slow query logging on, you will need to add 3 lines to /etc/mysql/my.cnf under the [mysqld] section:
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=2
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=2
Restart your mysql :-
#/etc/init.d/mysqld restart
To test if it is working correctly,
simply run a SELECT
SLEEP(x) query where "x" is longer than the
long_query_time
root@anneke:~#
mysql -e 'SELECT SLEEP(5);'
Then you can look at the logfile and
check id your "slow" query is there:
less
/var/log/mysql/mysql-slow.log
No comments:
Post a Comment