How to record SQL statements executed by MySQL? Most of the time, we need to know which SQL statements MySQL has executed, such as the damage caused after MySQL is injected. As long as there is a record of SQL statements, you can know the situation and make countermeasures. The server can enable the SQL statement record function of MySQL to indirectly detect the behavior of the client program.
The method is simple: edit/etc/my. in the cnf file, add the log =/var/lib/mysql/SQL _row.log line under the [mysqld] section (the log path is defined as needed ).
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 log=/var/lib/mysql/sql_row.log # Disabling symbolic-links is recommended to prevent assorted security risks; # to do so, uncomment this line: # symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
After modification, restart MySQL:
Service mysql restart # or/etc/init. d/mysqld stop/etc/init. d/mysqld start
Now you can go to the SQL _row.log file in the/var/lib/mysql/path to see when MySQL has executed the programs.