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

Log types in MySQL (2)-General query log

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

Share

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

Brief introduction

General query log records connections and disconnections from the client, as well as every SQL statement sent from the client.

Log content format

The General query log can be recorded in a file or in a table in the following format:

The time, thread ID, command type, and statements executed are recorded in the file

Examples are as follows:

When the log is recorded in the table, the account information is also recorded, as shown in the following example:

Record time

General Query Log records when the database receives a statement from the client. This means that the order of the General Query Log may be different from the order in which the actual statements are executed.

Setting method

General Query Log can be opened when the database is started or when the database is running.

Before the database starts:

Set-- general_log to open the log

Set-- log_output= [FILE,TABLE,NONE] to determine where the logs are stored.

Set-- general_log_file=file_name to determine the name and directory of the log file.

While the database is running:

Modify global variables to modify log settings

Modify the values of general_log, log_output, and general_log_file to modify the relevant settings, for example:

SET GLOBAL general_log=1

SET GLOBAL log_output='FILE'

In addition, you can disable or enable the currently connected General query log by setting the value of sql_log_off to ON or OFF.

Other

The database writes the log to a file or table based on the value of log_output.

But regardless of the value of log_output, a startup message is written to the log file when the log is opened (or when the log file is refreshed). Examples of startup information are as follows:

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