当前位置:网站首页>[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
边栏推荐
- Easy to use tcp-udp_ Debug tool download and use
- Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
- Golang DNS write casually
- Image fusion -- challenges, opportunities and Countermeasures
- Go learning notes (3) basic types and statements (2)
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- synchronized 解决共享带来的问题
- 1202 character lookup
- Circular reference of ES6 module
- Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
猜你喜欢
Uibehavior, a comprehensive exploration of ugui source code
Configuring OSPF load sharing for Huawei devices
将 NFT 设置为 ENS 个人资料头像的分步指南
CISP-PTE实操练习讲解
Let the bullets fly for a while
Hcip day 16
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
Nacos Development Manual
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
随机推荐
Summary of MySQL index failure scenarios
Permutation and combination function
1202 character lookup
[research materials] 2021 live broadcast annual data report of e-commerce - Download attached
sys.argv
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
VMware 虚拟化集群
Make learning pointer easier (3)
Circular reference of ES6 module
Use dumping to back up tidb cluster data to S3 compatible storage
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
让学指针变得更简单(三)
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
MFC 给列表控件发送左键单击、双击、以及右键单击消息
Easy to use tcp-udp_ Debug tool download and use
好用的TCP-UDP_debug工具下载和使用
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
备份与恢复 CR 介绍
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers