MySQL Log System

Source: Internet
Author: User

MySQL Log System

There are five log types in MySQL. Different log types have different log information. Here, the log types are as follows:

Error Log:

1. Records Information during server startup and Shutdown

2. Records Errors generated during server operation

3. records the information generated when the time scheduler runs an event.

4. records the information generated when the slave server starts the process from the server.

MySQL-related log files

Variables related to error logs include:

Log_error =/PATH/TO/ERROR_LOG_FILENAME

Define the error log file. It can be used in configuration files at the global or session level and is a non-dynamic variable.

Log_warnings = #

Set whether to record warning information into the error log. The default value is 1, indicating that it is enabled. You can set it to 0 to disable it; when the value is greater than 1, it indicates that the "failed connection" and "Access Denied" Errors generated when the new connection is initiated are also recorded in the error log.

General query log: records all information related to query statements. Because query statements are frequently used, this function is usually disabled.

The following variables are used to query logs:

Log = {YES | NO}

Whether to enable logging of all query statement information in general query log, which is usually OFF by default. MySQL 5.6 has been deprecated.

SQL _log_off = {ON | OFF}

It is used to control whether to prohibit logging general query log information into the query log file. The default value is OFF, indicating that the record function is not prohibited. You can modify the value of this variable at the session level, but it must have the SUPER permission. The scope is global and session level, which is a dynamic variable.

Slow query log: If the query time exceeds the specified time, it is called slow query. This query may be caused by the lock mechanism or other mechanisms. The query time is calculated from the start of the query to the end of the query, rather than based on the execution time on the cpu.

Variables related to slow query logs include:

Long_query_time = #

Set the statement execution time for the difference between slow query and general query. The statement execution time here is the actual execution time, rather than the execution time on the CPU. Therefore, the server with heavy load is more prone to slow queries. The minimum value is 0, and the default value is 10, in seconds. It also supports millisecond-level resolution. It can be used in configuration files at the global or session level and is a dynamic variable.

Log_slow_queries = {YES | NO}

Whether to record slow query logs. A slow query is an event that exceeds the scheduled duration set by the long_query_time parameter. MySQL 5.6 changed this parameter to slow_query_log. The scope is global. It can be used in configuration files and is a dynamic variable.

Slow_query_log = {ON | OFF}

Set whether to enable slow query logs. 0 or OFF indicates disabled, 1 or ON indicates enabled. The output location of log information depends ON the definition of the log_output variable. If the value is NONE, even if slow_query_log is ON, no slow query information is recorded. The range is global. It can be used in option files and is a dynamic variable.

Log_query_not_using_indexes = {ON | OFF}

Set whether to record query operations without indexes to slow query logs. The scope is global. It can be used in configuration files and is a dynamic variable.

Log_output = {TABLE | FILE | NONE}

Defines the storage methods for general query logs and slow query logs, which can be TABLE, FILE, NONE, or a combination of TABLE and FILE (separated by commas). The default value is TABLE. If NONE appears in the combination, other settings will be invalid. At the same time, no log information is recorded whether or not the log function is enabled. The scope is global. It can be used in configuration files and is a dynamic variable.

Log_query_not_using_indexes = {ON | OFF}

Set whether to record query operations without indexes to slow query logs. The scope is global. It can be used in configuration files and is a dynamic variable.

Slow_query_log_file =/PATH/TO/SOMEFILE

Set the name of the slow query log file. The default is hostname-slow.log, but can be modified through the -- slow_query_log_file option. The range is global. It can be used in option files and is a dynamic variable.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page

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.