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

Mysql log analysis

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

Share

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

Because the log file is an important reference to grasp the running status of the database, so the maintenance of the log file is also of great significance. The log types of mysql are binary log, error log, general log, slow query log.

Add log analysis to the module

Log-bin=mysql_bin / / binary log

Log-error=/usr/local/mysql/data/mysql_error.log / / error log

General_log=ON / / enable general log

General_log_file=/usr/local/mysql/data/mysql_general.log / / General Log

Slow_query_log=ON / / enable slow log

Slow_query_log_file=mysql_slow_query.log / / slow log file path

Long_query_time=5 / / delay 5 seconds to record as slow log

Restart the service to generate log files

Binary log

Binary logs are used to record all statements that have updated the data or have potentially updated the database, recording changes to the data, and the main purpose is to restore the database to the maximum extent possible when the data is recovered. Under the data folder, named after mysql-bin, when the amount of data is large, it will be automatically divided into multiple log files, with numbers as the extension.

Check the binary log method: mysqlbinlog-- no-defaults mysql-bin.00000*

Error log

The error log mainly records the relevant information when mysql starts or stops, as well as any errors that occur during operation.

General log

The general log is used to record all connections and statements of mysql.

Cat / usr/local/mysql/data/mysql_general.log / / View General Log

Slow log

Slow logging records all sql statements that take more than long_query_time seconds to execute, and is used to find those query statements that take a long time to execute so that they can be optimized.

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