Mysql log type _ MySQL

Source: Internet
Author: User
Mysql log type bitsCN.com

1. [Error Log] --- record problems that occur when mysqld is started, running, or stopped

You can use the -- log-error [= file_name] option to specify the location where mysqld saves the error log file. If the file_name value is not specified, mysqld uses the error log name host_name.err and writes the log file to the data directory. If you execute flush logs, the error log uses-old to rename the suffix and mysqld to create a new empty log file (if the -- log-error option is not provided, it will not be renamed ).

2. Slow Log: records all queries whose execution time exceeds long_query_time seconds or where no index is used. records can be dynamically enabled and disabled after MySQL.

When the -- log-slow-queries [= file_name] option is enabled, mysqld writes a log file containing all SQL statements whose execution time exceeds long_query_time seconds. Obtaining the initial lock time is not counted as the execution time. If the file_name value is not given, no host name is provided by default, and the suffix is-slow. log. If the file name is provided but not the absolute path name, the file is written to the data directory. After the statement is executed and all the locks are released, the slow query log is recorded. The record sequence can be different from the execution sequence.

Slow query logs can be used to locate long-running queries and optimize them. However, it is difficult to check long and slow query logs. To make it easier, you can use the mysqldumpslow command to obtain the query summary displayed in the log to process slow query logs.

The settings that affect slow query log records include:

Log-slow-admin-statements ----- slow query statements, such as optimize table, analyze table, and alter table.

Log-queries-not-using-indexes
Long_query_time = 1

3. [General query Log General Qurey Log]-records the established client connection and all statements executed. records can be dynamically enabled and closed after MySQL.

If you want to know what happened inside mysqld, you should use the -- log [= file_name] or-l [file_name] option to start it. If the file_name value is not specified, the default name is host_name.log. All connections and statements are recorded in log files. This log may be useful when you suspect that an error occurs on the client and want to know exactly the statement sent from the client to mysqld.

Mysqld records the query logs according to the order it receives, which may be different from the execution order. This is different from the update log and binary log. they record the log after the query is executed but before any lock is released (the query log also contains all statements, binary logs do not contain statements that only query data ).

4. [binary log Binlog]-records all statements for changing data and is also used for copying

The binary log contains all statements that update data or have potentially updated data (for example, no DELETE matching any row. The statement is saved as an "event" and describes data changes. The binary log also contains information about the execution time of each statement to update the database.

When the -- log-bin [= file_name] option is enabled, mysqld writes a log file containing all the SQL commands for updating data. If the file_name value is not given, the default name is the host name followed by-bin. If the file name is provided but the path is not included, the file is written to the data directory. We recommend that you specify a file name.

If you provide an extension (for example, -- log-bin = file_name.extension) in the log name, the extension is removed and ignored. Mysqld adds a digital extension after each binary log name. This number is increased every time you start the server or refresh the log. If the current log size reaches max_binlog_size, a new binary log is automatically created. If you are using a large transaction, the binary log will exceed max_binlog_size: The transaction is fully written into a binary log, and never written into different binary logs.

To know which different binary log files are used, mysqld also creates a binary log index file that contains the names of all binary log files used. By default, the file name is the same as that of the binary log file. the extension is '. index '. You can use the -- log-bin-index [= file_name] option to change the file name of the binary log index file. When mysqld is running, you should not manually edit the file; otherwise, mysqld will become messy.

You can use the reset master statement to delete all binary log files, or use the purge master logs to delete only some binary files.

When mysql is used for master-slave replication, the slave database corresponding to the binlog of the master database will also generate

Relay log file relay_log [= file_name],

Relay log index file relay-log-index [= file_name]

Binlog location information file of the current master database: master-info-file [= file_name]

Relay-log-info-file [= file_name]

Note: with binary logs and relay logs, the slave database can enable log-slave-updates = 1 to build a M-M architecture.

BitsCN.com

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.