Log type in MySQL (ii)-general query log

Source: Internet
Author: User

Brief introduction

General query log records the connection and disconnection of the client and every SQL statement sent from the client.

Log Content Format

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:

Recording time

General Query Log is logged when the database receives a statement from the client. This means that the order of the general Query log may differ from the order in which the actual statements are executed.

Setup method

General Query Log can be turned on when the database is started, or it can be opened when the database is running.
Before the database starts:
Set--general_log to turn on logging
Set--log_output=[file,table,none] To determine where the log is 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, 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 current connection's 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.
However, regardless of the value of Log_output, when the log is turned on (or when the log file is refreshed), a startup message is written to the log file. The boot information example is as follows:

Log type in MySQL (ii)-general query log

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.