How to record SQL statements executed by MySQL? _ MySQL

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.