当前位置:网站首页>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 .
边栏推荐
- review.js ppt数学公式无法显示
- How does Eldon's ring of the law get lune quickly? Introduction to the fastest and safest method for obtaining lune
- Is it really hopeless to choose electronic engineering and be discouraged?
- VC Hacon Joint Programming genimage3extern writeimage
- PHP converts total seconds to hours, minutes and seconds
- Module 8 operation
- Process creation fork (), demise wait()
- Business opportunities with an annual increase of 3billion - non cage eggs or a new blue ocean for export to ASEAN
- Detailed explanation of IO flow basic knowledge -- file and IO flow principle
- typescript的装饰器(Decorotor)基本使用
猜你喜欢

Storage system overview

进程会计、进程时间、守护进程

基于微信电子书阅读小程序毕业设计毕设作品(4)开题报告

Reading small program based on wechat e-book graduation design (4) opening report

Demand and business model analysis -6- five topics

unity websockt一些知识:

存储体系概述

解释器文件

Reading small programs based on wechat e-book graduation design works (7) Interim inspection report

什么是数据驱动
随机推荐
Process accounting, process time, daemon
94. analyze the content in the web page
5g R17 standard is frozen. What does it say?
Ctfshow-web266 (deserialization)
Demand and business model innovation-4-strategy
Php+flash large file breakpoint continuation function sharing
New product launch
腾讯云TDP-virt-viewer win客户端的软件使用
torch 网络模型转换onnx格式,并可视化
硬件测试之—纹波测试为什么不要使用接地夹子
How mysterious is "PIP not an internal or external command, nor a runnable program or batch file"
Wechat e-book reading applet graduation design work (6) opening defense ppt
Module 8 fonctionnement
进程的创建fork()、消亡wait()
设备管理-借还模块界面代码
Add, delete, modify and query mysql, common MySQL commands
Equipment management - borrowing / returning module interface code
review.js ppt数学公式无法显示
Software usage of Tencent cloud TDP virt viewer win client
Test prerequisites: recommend a special cross platform app performance test tool!