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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. What is the MySQL Enterprise Monitor?
  2. MySQL Enterprise Backup (MEB): Lock the Tables While Making the Backup?
  3. How to List Tables Per Tablespace In MySQL Cluster
  4. Beginners Guide to Management of MySQL Cluster Log Files
  5. How to install and configure MySQL sys schema
  6. “expect” script to provide password to mysql_config_editor
  7. Understanding MySQL Pluggable Authentication
  8. Configure MySQL Router to Auto Restart of Failure using systemd
  9. How to set the default character set in MySQL and how to propagate it in a master-master replication scenario
  10. MySQL : How To Find the Slowest Queries

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright