How to check Audit logs in MySQL :

audit logs in mysql

Do you know why audit logs are required in MySQL and if you are looking for the same, then this article is for you. Today in this article, we will learn about audit logs in MySQL and their importance. Audit logs are the logs used to capture the activities performed in the database.

Importance :

i) To capture the activities performed in the database, an audit log is required
ii) For security purposes also, to keep some of the activities audit logs are required.

Policies of Audit Log in MySQL :

There are 4 types of policies for Audit logs in MySQL.

  1. ALL: It will capture all the login information, all queries with user information
  2. LOGIN: It will capture only the login details with usernames
  3. Queries: It will capture the Queries only, not the login details
  4. NONE: It will capture nothing

How to Check if Audit is enabled in MySQL :

By default, audit will not be enabled in MySQL, we can check the audit logs in MySQL by issuing the below command :

mysql> SELECT * FROM information_schema.PLUGINS WHERE PLUGIN_NAME LIKE ‘%audit%’;
Empty set (0.04 sec)

mysql> SHOW variables LIKE ‘audit%’;
Empty set (0.03 sec)

mysql>

No output means the audit plugin is not installed. So we have to install the audit plugin by issuing the below command. Then you will be able to install the audit log plugin.

INSTALL PLUGIN audit_log SONAME 'audit_log.so';

After that, we can enable the auditing by modifying the parameter audit_log_format in my.cnf file and we need to restart the mysqld services as well.

Audit Log Formats :

There are 3 types of audit log formats in MySQL. So we can modify the audit_log_format parameter with any one of those parameters as well.

i) OLD/NEW (XML) :

ii) JSON:

iii) CSV:

Hope you have got a brief idea of Audit logs in MySQL. Also, you can refer to the MySQL Doc to get more information on this.

Our Other MySQL Related Articles :

Leave a Reply