"mysql-bin.xxxxx" files taking up Disk Space on AEM Forms

Issue

On an AEM Forms installation, you may notice "mysql-bin.xxxxx" files are generated by MySQL database and take up considerable disk space:

rtaimage_2_

Environment

AEM Forms all version
MySQL database

Cause

This behavior is caused because Binary Logs are enabled on the MySQL database. This option is enabled in the "my.ini" configuration file used to initialize the MySQL database:

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
 
# binary logging format - mixed recommended
binlog_format=mixed

Resolution

You can safely purge those files using either of the following queries:

SHOW BINARY LOGS;
PURGE BINARY LOGS TO 'mysql-bin.xxxx'

(Replace xxxx in the PURGE command with the highest running number obtained from the SHOW BINARY LOGS; command).

Or:

PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';

(Replace '2008-04-02 22:46:26' with today's date to purge all files)

To avoid any further increase, you can either disable Binary Logs using:

SET sql_log_bin = 0;

Or set up a purge rotation:

SET GLOBAL expire_logs_days = 3;