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

What is the structure of the mysql log

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "mysql log structure is how", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "mysql log structure is how" it!

I. MySQL error log

/ home/mysql3306/logs/mysql-error.log

If the database fails, the error log is the first log to be queried

Delete error log

Log file for MySQL (error log)

Version 5.5.7 only rebuilds the error log, that is, unless the error log is deleted

Otherwise, it will not affect the online error log.

Note: after you delete the error log, it will not be rebuilt automatically. Flush logs or restart the data library is required.

Mysqladmin-u root-p flush-logs

Or

Mysql > flush logs

II. Mysql general log

Record all executed statements, but after opening the pressure on the database server is more serious. It is not recommended to set up the log on a daily basis. In some cases, such as statistical summary SQL, audit can consider temporarily enabling general log, otherwise problems will easily occur.

Related parameters:

Mysql > show variables like'% general%'

+-- +

| | Variable_name | Value |

+-- +

| | general_log | OFF |

| | general_log_file | / home/mysql3306/mysql3306/mysql5.log |

+-- +

III. Mysql slow log

Record the execution of SQL statements that exceed the time threshold to determine which sql is slow to execute

Mysql > show variables like'% slow%'

+-+

| | Variable_name | Value |

+-+

| | log_slow_admin_statements | ON |

| | log_slow_slave_statements | ON |

| | slow_launch_time | 2 | |

| | slow_query_log | ON |

| | slow_query_log_file | / home/mysql3306/logs/mysql-slow.log |

+-+

Click (here) to collapse or open

Set global slow_query_log='ON'

Set global long_query_time=1

Log_queries_not_using_indexes: records queries that do not use indexes

Log_throttle_queries_not_using_indexes:# sets the number of unused indexes logged to the log per minute. Beyond this number, only the number of statements and the total time spent are recorded.

Min_examined_row_limit: the number of rows to be checked is greater than or equal to N before it is recorded as a slow query, provided that the long_query_time and log-queries-not-using-indexes constraints are met.

Log_slow_admin_statements: whether administrative statements are recorded or not

Log_slow_slave_statements: whether the statement execution from the library is recorded or not

-mysqldumpslow tool

-s, which indicates how it is sorted. C, t, l, r are sorted by the number of records, time, query time, and the number of records returned.

Ac, at, al, ar, indicating the corresponding flashback

-t, which means top n, that is, how many previous pieces of data are returned.

-g, a regular matching pattern can be written later, which is case-insensitive.

For example:

/ path/mysqldumpslow-s r-t 10 / database/mysql/slow-log

Get the 10 queries that return the most recordsets.

/ path/mysqldumpslow-s t-t 10-g "left join" / database/mysql/slow-log

Get the query statements with left links in the first 10 items sorted by time.

Thank you for your reading, the above is the "mysql log structure is how" the content, after the study of this article, I believe you have a deeper understanding of the mysql log structure of this problem, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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