Home >Database >Mysql Tutorial >How to Enable MySQL Slow Query Log Without Restarting the Server?
How to Enable MySQL Slow Query Log Without Server Restart
Q: I can only set the slow query threshold with the method recommended at http://crazytoon.com/2007/07/23/. Is there anything else needed, such as specifying a filepath?
A: According to the MySQL documentation, the default slow query log file name is host_name-slow.log located in the data directory. If you don't see a log file when running SHOW VARIABLES, it's likely because you're using MySQL version 5.0.77 or earlier. For these versions, use the following command:
SET GLOBAL log_slow_queries = 1;
However, since MySQL 5.1, you can use the following command:
SET GLOBAL slow_query_log = 'ON';
Remember to flush the logs with FLUSH LOGS.
The above is the detailed content of How to Enable MySQL Slow Query Log Without Restarting the Server?. For more information, please follow other related articles on the PHP Chinese website!