Docs

  1. Home
  2. Docs
  3. Server
  4. How to Manage Binary Logs in FlyWP

How to Manage Binary Logs in FlyWP

Binary logs are an essential part of MySQL’s functionality, enabling point-in-time recovery and replication. However, without proper management, they can accumulate and consume significant disk space. This guide explains how to configure binary log expiration settings or manually purge logs in FlyWP.

First, Once you’ve successfully connected to your server via SSH using the command:

ssh [email protected]


1. Adjust Binary Log Expiry Time

To manage the binary logs’ lifecycle, you can configure their expiration time by editing the MySQL configuration file.

Steps:

  1. Locate the Configuration File
    Open the MySQL configuration file located at:
    cd /home/fly/.fly/config/mysql/my.cnf
    Image
  2. Edit the Configuration File
    Modify the following section to enable and configure binary log expiration:
    # Binary Log Settings
    # skip-log-bin
    binlog_expire_logs_seconds=259200 # 3 days

Adjust the binlog_expire_logs_seconds setting according to your needs:
binlog_expire_logs_seconds=259200
(259200 seconds = 3 days. Modify as per your requirements.)

Turning Off Binlog Completely

To permanently disable binary logging, you need to edit the MySQL or MariaDB configuration file (my.cnf) and add the skip-log-bin directive.

Open the MySQL configuration file located at:

cd /home/fly/.fly/config/mysql/my.cnf

In the configuration file, make sure the skip-log-bin line is not commented out to disable binlog completely.

skip-log-bin

  1. Save and Exit (Save the changes and close the file):
    Press Ctrl + O, then Enter to save.
    Press Ctrl + X to exit.
  1. Restart MySQL
    Apply the changes by restarting the MySQL service:
    docker compose -f /home/fly/.fly/docker-compose.yml restart mysql

2. Manually Purge Binary Logs

If you prefer to clean up binary logs manually, you can purge them using the following command.

Steps:

Execute the Purge Command
Run the following command to delete all binary logs up to the current date and time:
docker compose -f /home/fly/.fly/docker-compose.yml exec mysql mysql --user="root" --password="{DB_ROOT_PASS}" -e "PURGE BINARY LOGS BEFORE NOW();"

Replace {DB_ROOT_PASS} with the root password for your MySQL database.

Verify the Cleanup
After purging, you can check the status of binary logs to ensure the cleanup was successful:

docker compose -f /home/fly/.fly/docker-compose.yml exec mysql mysql --user="root" --password="{DB_ROOT_PASS}" -e "SHOW BINARY LOGS;"


Important Notes:

  • Understand Your Requirements:
    Setting a shorter expiration time can help control disk usage, but make sure it aligns with your backup and replication needs.
  • Test Changes Safely:
    Always test configuration changes in a development or staging environment before applying them to production.
  • Backup Your Data:
    Before purging binary logs or making configuration changes, ensure you have a recent backup of your database to prevent data loss.

By following these steps, you can effectively manage binary logs in FlyWP, optimize performance, and ensure your storage resources are used efficiently. If you have further questions, feel free to reach out to our support team!