1. MySQL taking up very quickly

At times your MySQL database server can be seen to be quickly consuming space. Once you notice such a thing, check and confirm that the most space is ing consumed by the Mysql folder /var/lib/mysql/

Once this is the case, log into your mysql as root and run the following

root@db_server:~# mysql -u root -p
Enter password:
Your MySQL connection id is 338
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> PURGE BINARY LOGS BEFORE '2021-05-03 00:00:00';
Query OK, 0 rows affected (24.64 sec)

mysql> SET GLOBAL binlog_expire_logs_seconds=864000;
Query OK, 0 rows affected (0.00 sec)

mysql> EXIT

The above command will delete all binary logs before 3rd May 2021. Please feel free to change the delete date. Like exp: the above command saved us about 126GB.

The second command sets the expiration time for binlogs to 10days.

Next, edit the my.cnf under the mysqld section and add this same rule under the [mysqld] section

binlog_expire_logs_seconds=864000

Restart mysql service and ensure that it is running

results matching ""

    No results matching ""