Home Database Mysql Tutorial 2.1 普通查询日志(The General Query Log)

2.1 普通查询日志(The General Query Log)

Jun 07, 2016 pm 03:08 PM
query the log usually Inquire

2.1普通查询日志(TheGeneralQueryLog) 普通查询日志记录mysqld所做的操作,比如当客户端连接或断开连接时,服务器都会向该文件中写入相关信息,客户端发出的SQL语句也会被记录到普通查询日志中。通过该日志文件可以查询客户端都提交了什么,这点对DBA会很有

2.1 普通查询日志(The General Query Log)

  普通查询日志记录mysqld所做的操作,比如当客户端连接或断开连接时,服务器都会向该文件中写入相关信息,客户端发出的SQL语句也会被记录到普通查询日志中。通过该日志文件可以查询客户端都提交了什么,这点对DBA会很有帮助,举例来说DBA怀疑客户端执行的操作有问题,就可以通过普通查询日志确定客户端究竟执行的是什么。

  Mysqld将接收到的语句按照接收的顺序(注意不是执行顺序)写到查询日志文件中。

  控制普通查询日志文件的输出主要有下列几点:

      
  • 在5.1.6版本之前,普通查询日志只能记入操作系统文件,要启用日志记录功能,可以在启动mysqld进程时附加--log[=file_name]参数(或简写形式-l [file_name]);  
  • 自5.1.6版本起,查询日志也可写到数据库系统中的专用表;  
  • 自5.1.6版本起,启用mysqld进程时附加--log[=file_name]或-l [file_name]参数启用查询日志记录功能,通过--log-output指定日志输出类型,有表(TABLE)和日志文件(FILE)两个选项;  
  • 自5.1.12版本起,新增--general_log[={0|1}]参数指定普通查询日志的输出状态,用来启用或禁用普通查询日志,默认值为1即启用,指定值为0时,表示禁用普通查询日志。  
  • 自5.1.29版本起,新增--general_log_file=file_name指定日志文件名,原--log和-l参数被废弃。

  如果指定参数时没有给查询日志指定文件名,则默认文件名为host_name.log,保存在mysql的data目录下。

  MySQL数据库运行时也可以控制查询日志的输出,主要通过系统环境变量:

      
  • general_log:设置值为0表示禁用,设置值为1表示启用;  
  • general_log_file:设置日志文件存储路径及文件名;  
  • log-output:控制输出类型,注意如果设置该参数值为"NONE",那么即使上面两个参数均启用日志输出,也不会有任何时间真正被输出,如果要输出日志到文件,那么log-output参数值中必须包含有"FILE"参数值。

  MySQL服务重新启动,或者刷新日志都不会生成新的普通查询日志文件,要生成新的日志文件,UNIX系统下可以通过mv命令,例如:

    shell> mv host_name.log host_name-old.log

    shell> mysqladmin flush-logs

    shell> cp host_name-old.log backup-directory

    shell> rm host_name-old.log

  如果是windows平台的话,在5.1.3版本之间,数据库系统运行过程中是不能修改日志文件名的,必须停止服务,然后重命令文件,然后再重启服务。

  从5.1.12版本开始,可以实时启用或禁用普通查询日志,不需要重启服务,例如:

    SET GLOBAL general_log = ¨OFF¨;

    SET GLOBAL general_log = ¨ON¨;

  如果要启用或禁用某个会话产生的普通查询日志,可以通过在会话级设置SQL_LOG_OFF参数的值为OFF/ON来控制。 
=================================================
连载:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

12306 How to check historical ticket purchase records How to check historical ticket purchase records 12306 How to check historical ticket purchase records How to check historical ticket purchase records Mar 28, 2024 pm 03:11 PM

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

How to check your academic qualifications on Xuexin.com How to check your academic qualifications on Xuexin.com Mar 28, 2024 pm 04:31 PM

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

After 2 months, the humanoid robot Walker S can fold clothes After 2 months, the humanoid robot Walker S can fold clothes Apr 03, 2024 am 08:01 AM

Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

Comparison of similarities and differences between MySQL and PL/SQL Comparison of similarities and differences between MySQL and PL/SQL Mar 16, 2024 am 11:15 AM

MySQL and PL/SQL are two different database management systems, representing the characteristics of relational databases and procedural languages ​​respectively. This article will compare the similarities and differences between MySQL and PL/SQL, with specific code examples to illustrate. MySQL is a popular relational database management system that uses Structured Query Language (SQL) to manage and operate databases. PL/SQL is a procedural language unique to Oracle database and is used to write database objects such as stored procedures, triggers and functions. same

Detailed explanation of log viewing command in Linux system! Detailed explanation of log viewing command in Linux system! Mar 06, 2024 pm 03:55 PM

In Linux systems, you can use the following command to view the contents of the log file: tail command: The tail command is used to display the content at the end of the log file. It is a common command to view the latest log information. tail [option] [file name] Commonly used options include: -n: Specify the number of lines to be displayed, the default is 10 lines. -f: Monitor the file content in real time and automatically display the new content when the file is updated. Example: tail-n20logfile.txt#Display the last 20 lines of the logfile.txt file tail-flogfile.txt#Monitor the updated content of the logfile.txt file in real time head command: The head command is used to display the beginning of the log file

How to check the activation date on Apple mobile phone How to check the activation date on Apple mobile phone Mar 08, 2024 pm 04:07 PM

If you want to check the activation date using an Apple mobile phone, the best way is to check it through the serial number in the mobile phone. You can also check it by visiting Apple's official website, connecting it to a computer, and downloading third-party software to check it. How to check the activation date of Apple mobile phone Answer: Serial number query, Apple official website query, computer query, third-party software query 1. The best way for users is to know the serial number of their mobile phone. You can see the serial number by opening Settings, General, About This Machine. . 2. Using the serial number, you can not only know the activation date of your mobile phone, but also check the mobile phone version, mobile phone origin, mobile phone factory date, etc. 3. Users visit Apple's official website to find technical support, find the service and repair column at the bottom of the page, and check the iPhone activation information there. 4. User

How to reorder multiple columns in Power Query via drag and drop How to reorder multiple columns in Power Query via drag and drop Mar 14, 2024 am 10:55 AM

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

Discuz database location query skills sharing Discuz database location query skills sharing Mar 10, 2024 pm 01:36 PM

Forum is one of the most common website forms on the Internet. It provides users with a platform to share information, exchange and discuss. Discuz is a commonly used forum program, and I believe many webmasters are already very familiar with it. During the development and management of the Discuz forum, it is often necessary to query the data in the database for analysis or processing. In this article, we will share some tips for querying the location of the Discuz database and provide specific code examples. First, we need to understand the database structure of Discuz

See all articles