I have an audit requirement where they want all database access (logins) logged. We have a very large distributed system of hundreds of mySQL servers (shards, slaves, slaves of slaves) that are serving a thousand queries per second. As a result, I can't just turn on general query logging as recommended in Audit logins on MySQL database, it'll be multiple GB/day per instance and kill our disk IO.
I've looked and see two options to do discretionary logging with filtering - an Oracle plugin and a McAfee plugin. The Oracle one requires you to be paying them $ for enterprise mySQL, and with hundreds of db servers I'm not really prepared to start doing that today. The McAfee one is brand new and I'm worried about stability on a large scale system like we have.
Any other good solutions to log only logins to our mySQL databases? It doesn't have to be integral to mySQL, we'd consider UNIX level port sniffing shenanigans if they'd scale.
mysql.dbprivilege table withDbset to 'audit',Hostset to '%', andUserset to '' (empty string) followed byFLUSH PRIVILEGESaccomplishes the same purpose, because the empty string is a wildcard. Curiously and conveniently, if you don't have a ''@'%' user in yourmysql.usertable (and you shouldn't), then this grant doesn't show up inSHOW GRANTSfor the user... but it still works. – Michael - sqlbot Mar 08 '13 at 04:30