当前位置:网站首页>MySQL log
MySQL log
2022-06-12 19:47:00 【TimeFriends】
MySQL journal
List of articles
In any database , There are all kinds of logs , It records all aspects of database work , To help database administrators track events that have occurred in the database ,MySQL No exception
Classification of logs
Error log 、 Binary log (binlog)、 Query log 、 Slow query log
Error log
The error log is MySQL One of the most important logs in , He recorded MySQL When starting and stopping , 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 , You can check this log first .
The log is enabled by default , The default storage directory is MySQL Data directory for , The default log file name is hostname.err(hostname It's the host name )
View log location command : show variables like '%log_error%';
see mysql Whether it is turned on binlog journal : show variables like '%log_bin%';
see binlog Format of log :show variables like '%binlog_format%';
Binary log (binlog)
The binary log records all DDL( Database definition language ) Statement and DML( Data operation language ) sentence , But it does not include data query statements , This log plays an extremely important role in data recovery in case of disaster ,MySQL Master-slave replication of , Through this binlog Realized .
Binary log ,MySQL8.0 It is on by default , Low version of the MySQL You need to start through the configuration file , And configuration MySQl Format of log ,windows System :my.ini,linux System :my.cnf
-- Configuration on binlog journal , The file prefix of the log is mysqlbin ---> The generated file name is as follows :mysqlbin.000001,mysqlbin.000002
log_bin = mysqlbin
-- Configure binary log format
binlog_format = STATEMENT
Log format
statement: The log format is recorded in the log file sql sentence , Every one of the items that modify the data sql Will be recorded in the log file , adopt mysql Provided mysqlbinlog Tools , You can see the text of each statement clearly , When master and slave copy , Slave Library (slave) Will resolve the log to the original text , And execute it again from the library .
row: The log format records the data changes of each line in the log file , Instead of recording sql sentence , Ultimate Reality : perform sql sentence :update tb_name set status=1 , If it is statement Log format , A line will be recorded in the log sql file , If it is row, Because it's updating the whole table , That is to say, every line of record will change ,row The data changes of each line will be recorded in the format log .
mixed: Mixed up statement and row Two formats .
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 set the configuration
-- This option is used to open the query log , Optional value :0 or 1;0 On behalf of closed 1 Representative opens
set general_log=1
-- Set the file name of the log , If not specified , The default filename is host_name.log
general_log_file=file_name
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 ,long_query_time The default is 10 second , The minimum is 0, Precision can be adjusted to microseconds
-- This parameter is used to control whether the slow query log is enabled Value for 0 and 1,1 Representative opens 0 On behalf of closed
slow_query_log=1
-- This parameter is used to specify the file name of the slow query log
slow_query_log_file=slow_query.log
-- This option is used to configure the query time limit , After this time, it will be considered as slow query , Will need to log , Default 10s
long_query_time=10
-- Check whether the slow log is enabled
show variables like '%slow_query_log%'
-- View the timeout of slow query
show variables like '%long_query_time%'
We sincerely invite you to join our family , There is not only technical knowledge sharing here , And the bloggers help each other . I still get red packets from time to time , There is a lottery every month , Game consoles and physical books ( Free shipping ), Let's keep warm together , Curl up . Create beauty C standing . Looking forward to your joining .
边栏推荐
- Fault analysis | a case of MySQL remote slave database replication delay
- JDBC interface summary
- The latest Ningxia construction safety officer simulation question bank and answers in 2022
- EFCore调优
- Simple understanding of anti shake function
- Promise to solve hell function calls can be used infinitely
- [generation confrontation network learning III] reading notes of Bigan paper and its principle understanding
- Torch network model is converted to onnx format and visualized
- 模塊八作業
- review. JS ppt math formula cannot be displayed
猜你喜欢

How does Eldon's ring of the law get lune quickly? Introduction to the fastest and safest method for obtaining lune

BigTable (II): how BigTable achieves scalability and high performance

设备管理-借还模块1

Demand and business model innovation-4-strategy

Demand and business model analysis-1-business model canvas

负数取余问题

用户权限和组权限

leetcodeSQL:578. Questions with the highest response rate

运算器的基本结构

vc hacon 联合编程 GenImage3Extern WriteImage
随机推荐
Original introduction to Jenkins' configuration options
今晚7:00 | PhD Debate 自监督学习在推荐系统中的应用
mysql的增删改查,mysql常用命令
运算器的基本结构
[games101] class note 8 - shading (shading frequency, graphics pipeline, texture mapping)
First build green, then build city
简单理解防抖函数
Fault analysis | a case of MySQL remote slave database replication delay
Simple understanding of anti shake function
Ctfshow-web265 (deserialization)
Theory + practice will help you master the dynamic programming method
Efcore tuning
基于微信电子书阅读小程序毕业设计毕设作品(5)任务书
Demand and business model innovation-4-strategy
Reading small programs based on wechat e-book graduation design works (7) Interim inspection report
3GPP RAN第一次F2F会议,都干了些啥?
开源深度学习框架PlaidML安装及测试
Leetcodesql: count the number of students in each major
5G R17标准冻结,主要讲了些啥?
Axure RP 9 for Mac(交互式产品原型设计工具)中文版