MySQL Slow Query Log

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