Records the SQL statements executed by MySQL, and records the SQL statements executed by MySQL.

Source: Internet
Author: User

Records the SQL statements executed by MySQL, and records the SQL statements executed by MySQL.

Comparing Oracle functions to learning Mysql will always discover highlights

Using the log mining skill in Oracle, you can find all records that have been executed;

Mysql also provides 3 methods {verified, I will record the specific practices}

Method 1: {verified}

Record all MySQL records
Open/etc/my. cnf
Under [mysqld], add
Log =/mnt/mydata/SQL. log

Restart mysql.

View the/mnt/mydata/SQL. log File

Note:

1. Because SQL. log has a large number of writes, pay attention to monitoring the size of IO and SQL. log;

2. After debugging or query is complete, we recommend that you disable the function.


Method 2: {not verified yet}

Query the SQL Syntax of Slow query:
Log_slow_queries =/var/log/mysql/mysql-slow.log.
Long_query_time = 2 (the SQL syntax is recorded for more than 2 seconds. It is also a method to set a short value to record the exception .)

Method 3: {not verified yet}

Set binlog for MySQL Replication:
 
Log_bin =/var/log/mysql/mysql-bin.log (this file uses the mysqlbinlog solution to see,
Mysqlbinlog mysql-bin.000042 | grep "T_ABC" | grep "columvalue"
Mysql records all INSERT/UPDATE/DELETE syntaxes here (but the syntax may be different from what you think). This is the log file to be written to SLAVE.

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.