Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 920
nwn Avatar asked Jan 01 '23 16:01

nwn


1 Answers

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'
like image 147
Madhur Bhaiya Avatar answered Jan 05 '23 14:01

Madhur Bhaiya