MySQL query log

MySQL

I wonder if there is an alternative for MySQL general query log. I would like to log (mostly) DDL statements, so I could trace what user DROP database/table etc. I know that enabling general query log may cause some performance degradation.

Questions:

  • can I log/filter DDL statements only with general query log
  • is there an option to specify a location on the file system for general query log
  • is there any other option/solution like logging to rsyslog for instance

Regards

EDIT: Fri Dec 6 10:57:31 GMT 2013

It looks like it's possible to set destination for general query log on the file system however I'm still looking for some alternative way due to performance impact.

Best Answer

A)

Different methods of auditing MySQL server:

  • The error log

  • The slow query log

  • The binary log

  • Custom made triggers

  • Using MySQL Proxy

  • The general log - You can change general log file path to other path by editing value for this General log file variable in my.cnf

You can refer this blog post: http://serge.frezefond.com/2013/04/how-can-we-audit-a-mysql-server/

B)

Using MySQL audit plugins

There are audit plugins released by MySQL and some of the forks, you can try them if you are concerned about security on your MySQL server

1) MySQL Enterprise Audit

Enterprise Audit uses the open MySQL Audit API to enable standard, policy-based monitoring and logging of connection and query activity executed on specific MySQL servers.

2) McAfee Audit Plugin - Open source

designed with an emphasis on security and audit requirements. The plugin may be used as a standalone audit solution or configured to feed data to external monitoring tools.

3) MariaDB Audit plugin

Auditing regulations are used by many enterprises to ensure they comply with laws and industry standards. Such regulations often require processes for tracking user access to data in databases.