Home > Database > Mysql Tutorial > How Can I Enable and Disable Query Logging in MySQL?

How Can I Enable and Disable Query Logging in MySQL?

Barbara Streisand
Release: 2024-12-28 14:54:26
Original
790 people have browsed it

How Can I Enable and Disable Query Logging in MySQL?

Logging Queries in MySQL

Monitoring database queries can provide valuable insights into system performance and security. To enable logging of all queries, you can turn on audit logging in MySQL.

Enabling Query Logging

To log queries for an hour and store them in a file, you can use the following steps:

SET global log_output = 'FILE';
SET global general_log_file='/desired/path/to/log_file.log';
SET global general_log = 1;
Copy after login

Disabling Query Logging

Once logging is enabled, you can disable it by setting the general_log variable to 0:

SET global general_log = 0;
Copy after login

By following these steps, you can efficiently log all queries in your MySQL database and monitor database activity effectively.

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