Home > Database > Mysql Tutorial > How to Enable MySQL Slow Query Log Without Restarting the Server?

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

Patricia Arquette
Release: 2024-10-31 09:36:02
Original
287 people have browsed it

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;
Copy after login

However, since MySQL 5.1, you can use the following command:

SET GLOBAL slow_query_log = 'ON';
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template