当前位置:网站首页>MySQL log classification: error log, binary log, query log, slow query log
MySQL log classification: error log, binary log, query log, slow query log
2022-07-26 04:24:00 【Dark horse programmer official】
MySQL Strong performance , It is one of the most widely used databases at present , With MySQL For learning the prototype, it is also convenient to master other databases later , Now let's give you Give a comprehensive explanation MySQL8.0 New features , From zero foundation to high-level one-stop learning , Combined with actual cases, we can gain something !
▼ MySQL8.0 introduction - Advanced learning notes :( Summary )
- The first 1 speak :SQL Overview and database system introduction
- The first 2 speak :MySQL brief introduction 、 Detailed installation steps and use
- The first 3 speak :MySQL Common graphics management tools
- The first 4 speak :MySQL Basic operation of database -DDL
- The first 5 speak :MySQL Basic operation of database -DML
- The first 6 speak :MySQL Classification of constraints 、 Function and usage
- The first 7 speak :MySQL Basic operation of database -DQL- The basic query
- The first 8 speak :MySQL Multi table operation of
- The first 9 speak :MySQL Aggregate functions 、 Date function 、 Window functions, etc
- The first 10 take :MySQL View introduction of 、 Create and other operations
- The first 11 speak :MySQL Stored procedure 、 Features and case exercises
- The first 12 speak :MySQL Triggers and other operations 、 matters needing attention
- The first 13 speak :MySQL The index of 、 classification 、 Characteristics, principles and related operations
- The first 14 speak :MySQL Storage engine classification and operation
- The first 15 speak :MySQL The business of 、 operation 、 Isolation level
- The first 16 speak :MySQL Lock mechanism :MyISAM Table locks 、InnoDB Row lock
One 、 Introduce
In any database , There are all kinds of logs , It records all aspects of database work , To help the database administrator track all kinds of events that have happened in the database .MySQL No exception .
Two 、 Classification of log
- Error log
- Binary log
- Query log
- Slow query log
3、 ... and 、 Error log
The error log is MySQL One of the most important logs in , It records when mysqld 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 on 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 instructions :
show variables like 'log_error%';
Four 、 Binary log -binlog
Binary log (BINLOG) It records all the DDL( Data definition language ) Statement and DML( Data manipulation 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=STATEMENTLog format
- STATEMENT
The log format is recorded in the log file SQL sentence (statement), 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 . such as , perform SQL sentence : update tb_book 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 .
-- see MySQL Whether it is turned on binlog journal
show variables like 'log_bin';
-- see binlog Format of log
show variables like 'binlog_format';
-- Check all the logs
show binlog events;
-- Check out the latest logs
show master status;
-- query-specified binlog journal
show binlog events in 'binlog.000010';
select * from mydb1.emp2;
select count(*) from mydb1.emp2;
update mydb1.emp2 set salary = 8000;
-- Start at the designated location , View the specified Binlog journal
show binlog events in 'binlog.000010' from 156;
-- Start at the designated location , View the specified Binlog journal , Limit the number of queries
show binlog events in 'binlog.000010' from 156 limit 2;
-- Start at the designated location , With offset , View the specified Binlog journal , Limit the number of queries
show binlog events in 'binlog.000010' from 666 limit 1, 2;
-- Empty all binlog Log files
reset master5、 ... and 、 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 following configuration :
# This option is used to open the query log , Optional value : 0 perhaps 1 ; 0 On behalf of closed , 1 Representative opens
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
-- see MySQL Whether the query log is enabled
show variables like 'general_log';
-- Open query log
set global general_log=1;
select * from mydb1.emp2;
select * from mydb6_view.emp;
select count(*) from mydb1.emp2;
select count(*) from mydb6_view.emp;
update mydb1.emp2 set salary = 9000;6、 ... and 、 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, The precision can reach microseconds .
# This parameter is used to control whether the slow query log is turned on , Value for : 1 and 0 , 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 , Beyond this time will be considered value slow query , Will need to log , Default 10s
long_query_time=10边栏推荐
- How to transfer English documents to Chinese?
- Matrix and Gauss elimination [matrix multiplication, Gauss elimination, solving linear equations, solving determinants] the most detailed in the whole network, with examples and sister chapters of 130
- Postman 导入curl 、导出成curl、导出成对应语言代码
- MATLAB绘图
- egg-sequelize TS编写
- Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
- APISIX 在 API 和微服务领域的探索
- How to write the abbreviation of the thesis?
- 数据仓库
- Threadpooltaskexecutor and ThreadPoolExecutor
猜你喜欢

I.MX6U-系统移植-6-uboot图形化配置

Threadpooltaskexecutor and ThreadPoolExecutor

MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection

What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep

荐书 |《学者的术与道》:写论文是门手艺

华为再发“天才少年”全球召集令,有人曾放弃360万年薪加入

dijango学习

Acwing刷题

Can literature | relationship research draw causal conclusions

HelloWorld case analysis
随机推荐
Acwing_12. 背包问题求具体方案_dp
Yadi started to slow down after high-end
UE4 获取玩家控制权的两种方式
Use of rule engine drools
Life related -- the heartfelt words of a graduate tutor of Huake (mainly applicable to science and Engineering)
Compiled by egg serialize JS
How does win11 set the theme color of the status bar? Win11 method of setting theme color of status bar
旋转数组最小数字
Share | 2022 big data white paper of digital security industry (PDF attached)
VM虚拟机 没有未桥接的主机网络适配器 无法还原默认配置
Unable to find sygwin.s file during vscode debugging
再获认可 | 赛宁网安连续上榜《CCSIP 2022中国网络安全产业全景图》
Threadpooltaskexecutor and ThreadPoolExecutor
图论:拓扑排序
AWS Support Plan
华为高层谈 35 岁危机,程序员如何破年龄之忧?
ASP. Net core actionfilter filter details
Matlab drawing
What model is good for the analysis of influencing factors?
Matrix and Gauss elimination [matrix multiplication, Gauss elimination, solving linear equations, solving determinants] the most detailed in the whole network, with examples and sister chapters of 130