top of page

[MySQL 101] Audit MySQL user activities with McAfee Audit Plugin

Updated: Sep 16, 2021

Storing, keeping track the user activities and alerting when abnormal action occur, and auditing is a abosultely important demand that every system administrators need.

In this article, we focus on Audit MySQL User Activities by using McAfee Audit Plugin: how to know when users login to MySQL, is there failed login (brute force???) or users change password...

When you - a DB admin - receive a request of audit, you will immediately think about built-in log of MySQL, general log as common. General Log is what exactly what we need, but General Log has too much information of query that we have to filter it or pay more time to cut it from your system before do something further. They ususally enable General Log when they need to debug, but the historical log is the pass you should forget when enable or disable sometime. So, McAfee make it right by creating a plugin that only log audit log to solve your headache.

Some candidates we should list here:

  • MySQL Enterprise Audit: you should prepare your money for this, too much money.

  • MariaDB Audit Plugin: built-in MariaDB installation package. You can NOT download separately, it mean you can not integrate it with MySQL. This is the link to download.

  • Percona Audit Log Plugin: as MariaDB mindset, you have to work with Percona.

  • McAfee Audit Plugin: Open source project, and still be maintain until now. Github: As you may know, McAfee is a giant cybersecurity company in the world, you may have a basic trust on them.

Setup & Configuration

Quite easy for newbie, or anyone knows how to work with Linux can do this. Just keep in mind that, installing the plugin need you to restart MySQL daemon to apply change.

The very first step, you need to download a version from here.

After downloading successfully, unzip it, you will receive the file: lib/

Check the plugin directory of MySQL by the command:

mysql> SELECT @@plugin_dir;
| @@plugin_dir           |
| /usr/lib/mysql/plugin/ |
1 row in set (0.00 sec)

Copy the file to /usr/lib/mysql/plugin/

$ sudo cp lib/ /usr/lib/mysql/plugin/

Edit the /etc/my.cnf, add some configuration to [mysqld] block:

# Install Plugin
# Log some activities: login, failed login (bruteforce) 
# Define log format as JSON
# Whitelist the users
# Define the queries that log output will mask the password.
# Define the query will be logged

Save the changes, and restart mysql service:

$ sudo systemctl restart mysqld

Verify the plugin as below:

mysql> show plugins;
mysql> show global status like 'AUDIT_version';

If yours have the same output as figure above, the plugin has been installed. Next, you can check the file /var/lib/mysql/data/mysql-audit.json for audit log.


399 views0 comments

Related Posts

See All


Rated 0 out of 5 stars.
No ratings yet

Add a rating
Stationary photo

Be the first to know

Subscribe to our newsletter to receive news and updates.

Thanks for submitting!

Follow us
bottom of page