Instance that records SQL statements executed by MySQL

Source: Internet
Author: User

This article will introduce you to a more useful function, that is, to record the SQL statements executed by MySQL in real time, so that we can easily troubleshoot various injection problems.


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 ).

The Code is as follows: Copy code

[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/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. pid


After modification, restart MySQL:

The Code is as follows: Copy code

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.

Related Article

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.