Home > Database > Mysql Tutorial > How Can I Enable and Disable MySQL Query Auditing for One Hour?

How Can I Enable and Disable MySQL Query Auditing for One Hour?

Patricia Arquette
Release: 2024-12-12 16:59:09
Original
666 people have browsed it

How Can I Enable and Disable MySQL Query Auditing for One Hour?

Enable Query Auditing in MySQL

If you're looking to monitor and log all queries executed on your MySQL database for an hour, you can turn on audit logging.

Audit Logging Configuration

To enable audit logging and dump the log to a file, execute the following commands in your MySQL console:

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 will configure the database to write all queries to the specified log file. After an hour, you can stop logging by executing:

SET global general_log = 0;
Copy after login

The above is the detailed content of How Can I Enable and Disable MySQL Query Auditing 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