MySQL Log analysis

Source: Internet
Author: User

由于日志文件是掌握数据库运行状态的重要参考,因此日志文件的维护也有十分重要的意义。 mysql的日志类型有二进制日志,错误日志,通用日志,慢查询日志。

Add log analysis to the module
Log-bin=mysql_bin//binary log
Log-error=/usr/local/mysql/data/mysql_error.log//error log
General_log=on//Turn on universal logging
General_log_file=/usr/local/mysql/data/mysql_general.log//General Log
Slow_query_log=on//Turn on slow log
Slow_query_log_file=mysql_slow_query.log//Slow log file path
Long_query_time=5//Delay 5 seconds recorded as slow log

Restart Service Build log file

Binary log
The binary log is used to log all statements that have updated data or have potentially updated the database, recording changes to the data, primarily to restore the database to the greatest extent possible when recovering data. In the Data folder, named after the Mysql-bin, when the volume is large, he will automatically split into multiple log files, with numbers as the extension.
To view the binary log method: Mysqlbinlog--no-defaults mysql-bin.00000*


Error log
The error log primarily records information about when MySQL starts or stops, as well as any errors that occur during the run.



General Log
The common log is used to record all MySQL connections and statements.

Cat/usr/local/mysql/data/mysql_general.log//View general logs

Slow log
Slow logging all SQL statements that execute longer than long_query_time seconds are used to find those query statements that have a long execution time to optimize for them.


MySQL Log analysis

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.