当前位置:网站首页>[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
边栏推荐
- IoT -- 解读物联网四层架构
- [cloud native] teach you how to build ferry open source work order system
- VMware virtualization cluster
- Vocabulary notes for postgraduate entrance examination (3)
- Understanding of law of large numbers and central limit theorem
- Secure captcha (unsafe verification code) of DVWA range
- "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
- Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
- Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
- IOT -- interpreting the four tier architecture of the Internet of things
猜你喜欢
Leetcode question brushing record | 203_ Remove linked list elements
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
【云原生】手把手教你搭建ferry开源工单系统
Online yaml to CSV tool
【MySQL】数据库的存储过程与存储函数通关教程(完整版)
Pointer advanced --- pointer array, array pointer
[research materials] 2021 China online high growth white paper - Download attached
Ruffian Heng embedded bimonthly, issue 49
wincc7.5下载安装教程(Win10系统)
Synchronized solves problems caused by sharing
随机推荐
Pyqt5 development tips - obtain Manhattan distance between coordinates
From monomer structure to microservice architecture, introduction to microservices
Analysis of pointer and array written test questions
Résumé des diagrammes de description des broches de la série ESP
All the ArrayList knowledge you want to know is here
IP lab, the first weekly recheck
Understanding of law of large numbers and central limit theorem
MFC sends left click, double click, and right click messages to list controls
MFC 给列表控件发送左键单击、双击、以及右键单击消息
[MySQL] database stored procedure and storage function clearance tutorial (full version)
使用 Dumpling 备份 TiDB 集群数据到兼容 S3 的存储
Image fusion -- challenges, opportunities and Countermeasures
What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
Leetcode question brushing record | 203_ Remove linked list elements
远程存储访问授权
[cloud native] teach you how to build ferry open source work order system
Circular reference of ES6 module
"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