Releem automatically enables the slow query log during installation. However, if manual configuration is required, administrators can follow these steps:
- Open your MySQL server's configuration file, which is typically named my.cnf or my.ini.
- Scroll to the [mysqld] section within this file.
- To activate the logging feature insert or update the following entry:
4. To specify where the logs will be stored insert or update the following entry:
- slow_query_log_file = '/path/filename';
5. By default, when the slow query log is enabled, it logs any query that takes longer than 10 seconds to run. Here, replace "threshold" with the number of seconds you would like to define as a "slow" query:
- long_query_time = threshold;
After making these adjustments, save your changes to the configuration file and restart the MySQL server to apply the new settings.
The slow query log can also be activated dynamically via runtime configuration by following the guidelines.
To activate the slow query log in MySQL console and execute
SET GLOBAL slow_query_log = 'ON'; at the MySQL prompt.
You can customize its behavior further by
1. adjusting the threshold for logging slow queries with
SET GLOBAL long_query_time = X; , where X is time in seconds
2. change the log file's location using
SET GLOBAL slow_query_log_file = '/path/filename'; , specifying your desired path and filename.