MySQL to open record executed SQL statement method

Source: Internet
Author: User
Tags what sql

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

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.