Enable slow query log on MySQL server

Set it temporarily, by running the following commands on mysql console:


set global slow_query_log = 1;
set global slow_query_log_file = '/var/log/mysql-slow.log';

the changes will be undone when mysql is restarted.

Set it permanently, by adding the following in “my.cnf” file:


slow-query-log=1
slow-query-log-file=/var/log/mysql-slow.log

The location of my.cnf varies by OS, but is often found in /etc/my.cnf, or /etc/mysql/my.cnf. After saving your changes, you will need to restart MySQL.

Leave a Reply

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