当前位置:网站首页>[MySQL] log
[MySQL] log
2022-07-06 08:24:00 【If you dare to fly, you will have the sky】
journal
1. Error log
The error log is MySQL One of the most important logs in , It records when MySQL When the service starts and stops , As well as information about any serious errors in the running process of the server . When there is any failure of the database that results in the failure of normal use , It is recommended to view this log first . The log is on by default , The default storage directory is /var/log/, The default log file name is mysqld.log.
# Check the error log
# /var/log/mysqlld.log
show variables like '%log_error%';
2. Binary log
Introduce
The binary log records all DDL sentence ( Data definition language ) and DML sentence ( Data manipulation language ), But it does not include query statements ( Such as :SELECT、SHOW). stay MySQL8 In the version , Binary log is on by default , The functions of binary log are as follows :
- Data recovery in case of disaster
- MySQL Master-slave replication of .
# View binary logs
# /var/lib/mysql/binlog
show variables like '%log_bin%';

- log_bin_basename: The base name of the binary log of the current database server ( Prefix ), The specific binary file name needs to be in this basename Add a number on the basis of ( Number from 000001 Start ).
- log_bin_index: Index file of binary log , Record the binary file associated with the current server .
Format
If we need to configure the format of binary log , Only need /etc/my.cnf Middle configuration binlog_format Parameters can be .
# View binary log format
show variables like '%binlog_format%';
see
Because logs are stored in binary , Can't read directly , You need to use the binary log query tool mysqlbinlog Check it out. .
Delete
For busy business systems , The binary log data generated every day is huge , If you don't clear it for a long time , It will take up a lot of disk space .
# Check the expiration time of binary log
show variables like '%binlog_expire_logs_seconds%';
Query log
The query log records all the operation statements of the client , Binary log does not contain query data SQL sentence . By default , The query log is not opened . If you need to open the query log , You can modify MySQL Configuration file for /etc/my.cnf file . After the query log is turned on ,MySQL Data storage directory , That is to say /var/lib/mysql/ It will appear in the directory mysql_query.log file . After that, all the operations of adding, deleting, modifying and checking the client will be recorded in the log file , After a long run , The log file will be very large .
# View query log
show variables like '%general%';
Slow query log
The slow query log records that all execution times exceed the parameters long_query_time Set the value and the number of scan records is not less than min_examined_row_limit All of SQL Statement log , Default not on .long_query_time The default is 10 second , The minimum is 0, The precision can reach microseconds .
By default , Management statements will not be recorded , Queries that do not use indexes for lookup are also not recorded . have access to log_slow_admin_statements And change this behavior log_queries_not_using_indexes
After all the above parameters are configured , All need to be restarted MySQL The server can take effect .
Reference resources :https://www.bilibili.com/video/BV1Kr4y1i7ru
边栏推荐
- "Designer universe" Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers | national economic and Informa
- 指针和数组笔试题解析
- 图像融合--挑战、机遇与对策
- [research materials] 2021 Research Report on China's smart medical industry - Download attached
- 【刷题】牛客网面试必刷TOP101
- [research materials] 2022 China yuancosmos white paper - Download attached
- 根据csv文件某一列字符串中某个数字排序
- Nacos Development Manual
- Analysis of pointer and array written test questions
- 在 uniapp 中使用阿里图标
猜你喜欢

Step by step guide to setting NFT as an ens profile Avatar

Leetcode question brushing record | 203_ Remove linked list elements

2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers

Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio

Pointer advanced --- pointer array, array pointer

Configuring OSPF load sharing for Huawei devices

Wireshark grabs packets to understand its word TCP segment

3. File operation 3-with

Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation

化不掉的钟薛高,逃不出网红产品的生命周期
随机推荐
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
Char to leading 0
Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
LDAP应用篇(4)Jenkins接入
Migrate data from a tidb cluster to another tidb cluster
The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
String to leading 0
leetcode刷题 (5.28) 哈希表
Online yaml to CSV tool
在 uniapp 中使用阿里图标
Introduction to backup and recovery Cr
3. File operation 3-with
C language custom type: struct
Wireshark grabs packets to understand its word TCP segment
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
LDAP application (4) Jenkins access
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
Understanding of law of large numbers and central limit theorem
[t31zl intelligent video application processor data]