HostOnNet Blog

MySQL Slow Query Log

Looking for Linux Server Admin or WordPress Expert? We can help.

MySQL Slow Query Log i used to find SQL query that are slow. To enable Slow Query Log, add following to /etc/my.cnf file under [mysqld] section.

[mysqld]
log_slow_queries       = /var/log/mysql/mysql-slow.log
long_query_time = 2

If you don’ have folder /var/log/mysql/, create it

mkdir /var/log/mysql/
chown mysql:mysql /var/log/mysql/

Now restart MySQL

service mysql restart

or

service mariadb restart

Posted in MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.