• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Rotate the MySQL Enterprise Audit Log Plugin Log Based On Size

By admin

Automatic rotation of the audit log is supported in MySQL Server 5.5.28 and later. This is achieved by adding the audit_log_rotate_on_size option to the MySQL configuration file with a value of the size when to rotate the log.

For example to rotate the log when it reached a size of 1G:

[mysqld]
audit_log_rotate_on_size = 1G

The size can also be changed dynamically:

mysql> SET GLOBAL audit_log_rotate_on_size = 1024*1024*1024;

How to Manually Rotate the MySQL Enterprise Audit Log

To rotate the MySQL Enterprise Audit Log two steps are required:

1. Rename the existing audit log, for example:

$ mv audit.log audit.log.1

2. Flush the log using the audit_log_flush variable:

SET GLOBAL audit_log_flush = 1;
Note: Flushing the audit log using audit_log_flush is only supported when audit_log_rotate_on_size = 0.

Privileges

As the audit_log_flush variable only exists in the GLOBAL scope, it requires the SUPER privilege to set it.

If you don’t want to grant that user the SUPER privilege (this privilege should be given sparingly) an option is to create a simple procedure that flushes the audit log and have that procedure executed with SQL SECURITY DEFINER. This way you can create the procedure with a user that has SUPER, and then grant EXECUTE on the procedure to the users who should be allowed to execute it.

MySQL : Stored Procedure For Rotating the Audit Log

Filed Under: mysql

Some more articles you might also be interested in …

  1. “Another MySQL daemon already running with the same unix socket” – error while starting MYSQL
  2. Beginners Guide to MySQL User Management
  3. How to backup and restore MySQL database
  4. How To Reset MySQL 8.0 Root Password On Windows
  5. How to Disable Client Access Control in MySQL
  6. MySQL – How to undo (rollback) a set of SQL statements
  7. Managing MySQL Using Systemd As A Non Root User
  8. How to obtain MySQL metadata (metadata access methods)
  9. How to Restart a MySQL Cluster without downtime
  10. Understanding mysqlcheck and myisamchk utilities

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary