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

谁说我不能喝 提交于 2020-05-13 13:54:08

问题


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.


回答1:


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';

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'


来源:https://stackoverflow.com/questions/53098836/how-to-enable-general-log-without-restarting-the-mysql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!