Chanler

Chanler

"Dark Horse MySQL" Three, Logs

Error Log#

The error log is one of the most important logs in MySQL. It records relevant information when mysqld starts and stops, as well as any serious errors that occur during the server's operation. When the database encounters any failures that prevent normal use, it is recommended to first check this log.

This log is enabled by default, stored in the default directory /var/log/, and the default log file name is mysqld.log. To check the log location:

show variables like '%log_error%'

Binary Log#

The binary log BINLOG records all data definition language (DDL) and data manipulation language (DML) statements, but does not include data query (SELECT, SHOW) statements.

Functions:

  1. Data recovery in case of disaster
  2. MySQL master-slave replication

In MySQL version 8, the binary log is enabled by default, and the relevant parameter is:

show variables like "%log_bin%"

image.png|500

image.png|500

Logs expire by default after 30 days.

image.png|500

Query Log#

The query log records all operation statements from the client. It is disabled by default and needs to be enabled by adding configuration items in the MySQL configuration file.

image.png|500

Slow Query Log#

The slow query log records all SQL statements that take longer than the specified parameter long_query_time and scan a number of records not less than min_examined_row_limit.

The slow query log slow_query_log is disabled by default, with long_query_time defaulting to 10 seconds.

By default, management statements are not recorded, and statements that do not use indexes are not recorded.

image.png|500

This article is synchronized and updated to xLog by Mix Space. The original link is https://blog.0xling.cyou/posts/mysql/mysql-3

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.