如何在不重新启动MYSQL服务器的情况下启用--general-log? [英] How to enable --general-log without restarting the MYSQL server?
问题描述
根据mysql文档,该标志可以动态更改.
According to the mysql documentation this flag is possible to change dynamically.
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. You will just need to execute the following queries to enable GLOBAL
logging (for all the other client sessions as well):
SET GLOBAL general_log = 'ON';
您还可以指定日志文件路径:
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'
这篇关于如何在不重新启动MYSQL服务器的情况下启用--general-log?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!