MySQL: Log Management: Generally

Source: Internet
Author: User

Generally, query logs and slow query logs can be written to the OS file system or as a log table of the MySQL system!

The log strap brings a lot of convenience, and of course it will bring a certain amount of system load to MySQL! Need to weigh. At the same time, the log table has its own characteristics compared with the normal MySQL table: It must be CVs or MyISAM engine; When alter or drop table, the log table must be disabled; the truncate table can be used normally; the insert, update, delete, and lock tables cannot be used; the flush tables with read lock and read only system variables have no effect on the log table; the entries in the log table do not carry out bin log records, so the replication function cannot be used in the log table. Flush tables and flush logs force write log tables and log files respectively. The log table is not recommended for partitioning!

 

Command and configuration options: [--] log_output = {file | table | none},... the default value is file.

Dynamic Global System variable: log_output = {file | table | none },......

Dynamic Session system variable: SQL _log_off = {on | off} -- whether the current connection is queried

 

 

General log query settings

 

Command and configuration options: [--] log [= file_name] -- before 5.1.6, only this option can be recorded in the OS file.

Later: Based on the settings that allow you to query logs to files: [--] log_output = File

Command and configuration options: [--] general_log = {1 (default: allowed) | 0} -- determines whether to perform general query log records.

Command and configuration options: [--] general_log_file = file_name -- determines the file name of the general query log

 

Dynamic System global variable: general_log = {0 | 1} | {off | on} -- dynamically determines whether to perform general query log records.

Global variable of the dynamic system: general_log_file = file_name -- dynamically determines the file name of the general query log

Dynamic Session system variable: SQL _log_off = {on | off} -- dynamically determines whether to query log records for the current session

 

 

Slow query log settings

Any query statement that exceeds the long_query_time time (second) setting and the min_examined_row_limit row setting is recorded in the slow query log.

Command and configuration options: [--] log records with log_slow_queries [= file_name] -- 5.1.6 and only this option determines whether to perform general slow Query

Later: Based on the settings that allow you to query logs to files: [--] log_output = File

Command and configuration options: [--] slow_query_log = {1 (default: allowed) | 0} -- determines whether to perform a log record for a general slow query.

Command and configuration options: [--] slow_query_log_file = file_name -- determines the log file name for slow query.

 

Dynamic Global System variable: slow_query_log = {0 | 1} | {off | on} -- determines whether to perform a log record for a general slow query.

Dynamic Global System variable: slow_query_log_file = file_name -- determines the log file name for slow query.

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.