I'd like to turn on MySQL's general query log for a single database only. By default, it records all statements sent to all databases, resulting in huge log files on servers with many databases.
Is it possible to only record statements sent to a particular database?
The general query log is a global log of all queries executed on a given server, so it is not possible to enable or disable it for a specific schema.
There is a variable called SQL_LOG_OFF
that disables general query logging for a specific connection, which maybe useful for you if you can isolate specific connections that use the schema for which you want to enable/disable the general query log:
SET SQL_LOG_OFF = 1;
Note that this only works for users with SUPER privilege, so it may not be useful for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With