问题
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