简体   繁体   English

如何在不重启MYSQL服务器的情况下启用--general-log?

[英]How to enable --general-log without restarting the MYSQL server?

According to the mysql documentation this flag is possible to change dynamically.根据 mysql 文档,此标志可以动态更改。

Property    Value
Command-Line Format --general-log
System Variable general_log
Scope   Global
Dynamic Yes
SET_VAR Hint Applies    No
Type    Boolean
Default Value   OFF

But by default this option is disabled.但默认情况下,此选项是禁用的。 But I need to enable this flag in order to see the logs without restarting the server.但是我需要启用此标志才能在不重新启动服务器的情况下查看日志。 What is the way to enable this without restarting the server.在不重新启动服务器的情况下启用此功能的方法是什么。

MySQL provides a System variable general_log , which specifies whether the general query log is enabled or not. MySQL 提供了一个系统变量general_log ,它指定是否启用通用查询日志。 You will just need to execute the following queries to enable GLOBAL logging (for all the other client sessions as well):您只需要执行以下查询即可启用GLOBAL日志记录(也适用于所有其他客户端会话):

SET GLOBAL general_log = 'ON';

You can also specify the log file path :您还可以指定日志文件路径

SET GLOBAL general_log_file = '/var/log/mysql/all.log';

Remember that when you restart the server, these settings will be lost.请记住,当您重新启动服务器时,这些设置将丢失。 To make the changes persistent, you will have to make changes in the configuration file.要使更改持久化,您必须在配置文件中进行更改。


If you want to disable the general query logging, you can do the following:如果要禁用常规查询日志记录,可以执行以下操作:

SET GLOBAL general_log = 'OFF'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM