MySQL query log
Unlike Oracle, MySQL does not add a large number of debugging entries to the source code. Recently, it suddenly needs to debug the SQL Execution Process of MySQL. So I checked it and found that there is only one mechanism called query log. After the switch is turned on, all executed SQL statements will be recorded, which is very detailed and can basically achieve debugging. This is the official query log function description:
The general query log is a general record of what mysqld is doing. the server writes information to this log when clients connect or disconnect, And it logs each SQL statement received ed from clients. the general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.
Mysqld writes statements to the query log in the order that it records es them, which might differ from the order in which they are executed. this logging order contrasts to the binary log, for which statements are written after they are executed but before any locks are released. (Also, the query log contains all statements, whereas the binary log does not contain statements that only select data .)
There are two ways to open the query log of MySQL:
1. Add the following startup parameters when starting MYSQL: "-- log [= file_name] Or-L [file_name] Option"
Before Version 5.1.6, the recorded query log can only be saved in one table in MySQL. After version 5.1.6, the query log can be saved in both table and file, in the database, a parameter named general_log has a value of 0 or 1, representing the start switch of query log, run "show variables like % log %" in MySQL to view all log-related parameters.
2. another way is to use the MySQL configuration file my. add a line "log = D:/temp_ SQL .log" to the end of INI. This method does not seem to be described in the official documentation, but is very practical.
In retrospect, Oracle was brave enough to leave the debug Code directly in the release, so as to maximize the guidance for error debugging and performance optimization during runtime. Now Oracle has acquired sun to own mysql. I don't know how this open-source free database will develop in the future.