Home >Database >Mysql Tutorial >How Can I Efficiently Trace Database Activity Across Multiple MySQL Servers?
How to Trace Database Activity in MySQL Across Multiple Servers
Need to monitor the last queries executed on multiple MySQL servers? Here's how you can accomplish this:
MySQL >= 5.1.12
For MySQL versions 5.1.12 and above, follow these steps to capture the queries globally:
- Execute SET GLOBAL log_output = 'TABLE'; - Execute SET GLOBAL general_log = 'ON';
Queries will be recorded in the table mysql.general_log.
Output to a File
If you prefer to store the queries in a file, specify the path and file name:
- SET GLOBAL log_output = "FILE"; - SET GLOBAL general_log_file = "/path/to/your/logfile.log"; - SET GLOBAL general_log = 'ON';
Benefits of Runtime Configuration
Using these runtime settings offers several advantages over editing configuration files:
For additional information, refer to the MySQL 5.1 Reference Manual's documentation on the general_log variable.
The above is the detailed content of How Can I Efficiently Trace Database Activity Across Multiple MySQL Servers?. For more information, please follow other related articles on the PHP Chinese website!