How does MySQL track SQL statements?
In project development, it is inevitable that you need to track SQL Execution statements on the database server. By tracking SQL Execution statements, we can determine that When Upper-layer applications are executing SQL statements, whether the database has executed SQL statements, whether the SQL statements executed are incorrect, and so on. In short, tracking SQL Execution statements on the database greatly facilitates error troubleshooting in database logic code writing.
We all know that SQL tracking uses an event probe in SQL SERVER. How can we track the executed SQL statements in MySQL?
Through some google and baidu, we found a simple but not the ultimate solution.
Solution
1. The idea is simple: Enable the MySQL log function and view the tracking log.
2. How to enable MySQL log:
[Configuration method in Windows]
Find my. ini in the Mysql Server Installation Directory, which is under the "C: \ Program Files \ MySQL Server 5.5" directory,
Find the [mysqld] field in my. ini and add: log = the log storage path/mysql. log
My Configuration:
After modifying my. ini, save the file and restart mysql to find the mysql. log File in C:/Users/Administrator.
Run an SQL statement on the MySQL client to view the mysql. log and track the SQL statements.
This article permanently updates the link address: