Viewing Executed Queries on MySQL Servers
Monitoring queries executed across multiple MySQL servers can be valuable for troubleshooting, performance analysis, and security auditing. Here are the methods to capture and access these queries:
Global Logging for Recent Queries (MySQL >= 5.1.12):
Set the log_output variable globally to "TABLE":
SET GLOBAL log_output = 'TABLE';
Turn on general logging:
SET GLOBAL general_log = 'ON';
File-Based Logging for Past Queries:
If you prefer to store logs in a file:
Set log_output to "FILE":
SET GLOBAL log_output = "FILE";
Specify the destination log file path in general_log_file:
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
Enable general logging:
SET GLOBAL general_log = 'ON';
Benefits of Runtime Configuration:
Using this method to activate logging has several advantages over modifying configuration files:
Additional Information:
For further details, refer to the MySQL 5.1 Reference Manual on Server System Variables:
https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_general_log
The above is the detailed content of How Can I Monitor Executed Queries Across Multiple MySQL Servers?. For more information, please follow other related articles on the PHP Chinese website!