This article mainly introduced the MySQL open record executed SQL statement method, the configuration method is very simple, this article directly gives the configuration example, needs the friend to be possible to refer to under
Overview
Many times, we need to know what SQL statements MySQL has executed, such as when MySQL is injected, need to know what hurt, and so on. As long as there is a record of the SQL statement, you can know the situation and make countermeasures. The server is the SQL statement logging function that can open MySQL, so it can detect the behavior of the client program indirectly.
Method
The Open method is simple: Edit the/etc/my.cnf file and add it below the [mysqld] section: Log=/var/lib/mysql/sql_row.log Line (the path of the log itself is defined as needed).
The code is as follows:
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Default to using the 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 does so, uncomment this line:
# symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
After the modification, remember to restart MySQL:
The code is as follows:
Service MySQL Restart
# or
/etc/init.d/mysqld stop
/etc/init.d/mysqld start