Home > Database > Mysql Tutorial > body text

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

Patricia Arquette
Release: 2024-10-31 09:58:42
Original
696 people have browsed it

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

Configuring MySQL Slow Query Log Without Server Restart

Question:

How can you activate MySQL's slow query log without the need for server restart?

Answer:

Dynamically activating the slow query log feature in MySQL requires specific steps, depending on the MySQL version used.

In MySQL versions 5.1 and later, use the following command:

SET GLOBAL slow_query_log = 'ON';
Copy after login

To prevent sensitive data from being stored in cleartext, execute the following command after enabling the log:

FLUSH LOGS;
Copy after login

Additional Considerations for MySQL 5.0:

Prior to MySQL 5.1, server restart was necessary to enable slow query logging. However, you can change the 'log_slow_queries' variable using 'SET GLOBAL' in MySQL 5.0, but it will display a "read-only variable" error.

Refer to MySQL documentation for configurations and log file location details:

  • Config File: Edit the "my.cnf" file and add "slow_query_log" within the [mysqld] section (requires server restart).
  • Command Line: Use "mysqld --log-slow-queries" during server startup.

The above is the detailed content of How to Enable MySQL\'s 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!