Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A simple understanding of mysql log management

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article is mainly about the log management of mysql, if you are interested, let's take a look at this article. I believe it is of some reference value to everyone after reading the log management of mysql.

/ etc/my.cnf

Error log error log troubleshooting / var/log/mysqld.log [enabled by default]

Bin log binary log backup incremental backup DDL DML DCL

Relay log Relay Log replication receives replication master

Slow log slow query log tuning query time exceeds the specified value

Error Log

Log-error=/var/log/mysqld.log

Binary Log

Log-bin=/var/log/mysql-bin/slave2

Server-id=2

Mkdir / var/lib/mysql-bin

# chown mysql.mysql / var/lib/mysql-bin/

# systemctl restart mysqld

Note:

Restarting mysqld will truncate flush logs, truncate reset master and delete all binlog rm-rf /

Delete part

PURGE BINARY LOGS TO 'mysql-bin.010'

PURGE BINARY LOGS BEFORE '2016-04-02 22 purl 46purl 26'

Pause current session only

SET SQL_LOG_BIN=0

SET SQL_LOG_BIN=1

Intercept binlog

All:

Mysqlbinlog mysql.000002

Datetime:

# mysqlbinlog mysql.000002-- start-datetime= "2018-12-05 10:02:56"

# mysqlbinlog mysql.000002-- stop-datetime= "2018-12-05 11:02:54"

# mysqlbinlog mysql.000002-- start-datetime= "2018-12-05 10:02:56"-- stop-datetime= "2018-12-05 11:02:54"

Position:

# mysqlbinlog mysql.000002-start-position=260

Mysqlbinlog mysql.000002-stop-position=260

# mysqlbinlog mysql.000002-start-position=260-stop-position=930

Slow Query Log

Slow_query_log=1

Slow_query_log_file=/var/log/mysql-slow/slow.log

Long_query_time=3

# mkdir / var/log/mysql-slow/

# chown mysql.mysql / var/log/mysql-slow/

# systemctl restart mysqld

View slow query log

Test: BENCHMARK (count,expr)

SELECT BENCHMARK (50000000)

The above log management details about mysql, are they helpful to you? If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report