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
Patricia ArquetteOriginal
2024-12-12 16:59:09672browse

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;

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;

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!

Statement:
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