当前位置:网站首页>[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
边栏推荐
- Colorlog结合logging打印有颜色的日志
- [untitled]
- 指针和数组笔试题解析
- Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
- 图像融合--挑战、机遇与对策
- ESP series pin description diagram summary
- 华为云OBS文件上传下载工具类
- Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
- 从 TiDB 集群迁移数据至另一 TiDB 集群
- Migrate data from a tidb cluster to another tidb cluster
猜你喜欢
ESP series pin description diagram summary
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
Wireshark grabs packets to understand its word TCP segment
Go learning notes (3) basic types and statements (2)
Ruffian Heng embedded bimonthly, issue 49
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
随机推荐
Let the bullets fly for a while
根据csv文件某一列字符串中某个数字排序
PLT in Matplotlib tight_ layout()
Ruffian Heng embedded bimonthly, issue 49
Grayscale upgrade tidb operator
Migrate data from CSV files to tidb
Learn Arduino with examples
Hcip day 16
logback1.3. X configuration details and Practice
2022.02.13 - NC002. sort
IP lab, the first weekly recheck
hcip--mpls
[research materials] 2021 China online high growth white paper - Download attached
备份与恢复 CR 介绍
VMware virtualization cluster
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
LDAP應用篇(4)Jenkins接入