"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Enable MySQL Slow Query Log Without Restarting the Server?

How to Enable MySQL Slow Query Log Without Restarting the Server?

Published on 2024-11-06
Browse:484

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.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3