当前位置:网站首页>[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
边栏推荐
- synchronized 解决共享带来的问题
- 【MySQL】锁
- [Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
- Vocabulary notes for postgraduate entrance examination (3)
- Circular reference of ES6 module
- 华为云OBS文件上传下载工具类
- Upgrade tidb with tiup
- Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
- 2. File operation - write
- The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
猜你喜欢

Pyqt5 development tips - obtain Manhattan distance between coordinates

2.10transfrom attribute

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

Pointer advanced --- pointer array, array pointer

根据csv文件某一列字符串中某个数字排序

Easy to use tcp-udp_ Debug tool download and use

How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
![[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map](/img/c3/1b6013bfb2441219bf621c3f0726ea.jpg)
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map

Go learning notes (3) basic types and statements (2)

PLT in Matplotlib tight_ layout()
随机推荐
Fibonacci sequence
CAD ARX gets the current viewport settings
升级 TiDB Operator
Leetcode question brushing record | 203_ Remove linked list elements
Flash return file download
From monomer structure to microservice architecture, introduction to microservices
Permutation and combination function
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Make learning pointer easier (3)
【云原生】手把手教你搭建ferry开源工单系统
ESP系列引脚说明图汇总
在 uniapp 中使用阿里图标
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
Asia Pacific Financial Media | designer universe | Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers
【MySQL】数据库的存储过程与存储函数通关教程(完整版)
PHP - Common magic method (nanny level teaching)
使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
化不掉的钟薛高,逃不出网红产品的生命周期
Ruffian Heng embedded bimonthly, issue 49
Day29-t77 & t1726-2022-02-13-don't answer by yourself