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;
Disabling Query Logging
Once logging is enabled, you can disable it by setting the general_log variable to 0:
SET global general_log = 0;
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!