Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the MySQL general query log be turned on for a single database only?

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?

like image 526
Ollie Glass Avatar asked Apr 01 '11 09:04

Ollie Glass


1 Answers

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.

like image 150
Ike Walker Avatar answered Sep 22 '22 13:09

Ike Walker