Home > Database > Mysql Tutorial > How Can I Log All MySQL Queries to a File for One Hour?

How Can I Log All MySQL Queries to a File for One Hour?

Patricia Arquette
Release: 2024-12-16 12:42:18
Original
635 people have browsed it

How Can I Log All MySQL Queries to a File for One Hour?

Log Output Configuration in MySQL

This question explores the capability of MySQL to enable query logging. The user seeks to monitor all queries for an hour and output the log to a file.

To achieve this, the following procedures are recommended:

SET global log_output = 'FILE';
SET global general_log_file='/Applications/MAMP/logs/mysql_general.log';
SET global general_log = 1;
Copy after login

This sequence of commands will commence logging of queries to the specified file. Once the desired time frame has elapsed, the logging can be disabled with the following command:

SET global general_log = 0;
Copy after login

By utilizing these methods, it is feasible to effectively monitor all queries within a specified period and store the resulting log for further analysis.

The above is the detailed content of How Can I Log All MySQL Queries to a File for One Hour?. 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