Symptoms
The /var/lib/mysql/
folder gets filled with mysql-bin.#######
files.
-rw-r----- 1 mysql mysql 1.1G Jan 3 23:15 /var/lib/mysql/mysql-bin.000095
-rw-r----- 1 mysql mysql 1.1G Oct 8 11:07 /var/lib/mysql/mysql-bin.000047
-rw-r----- 1 mysql mysql 1.1G Feb 7 2022 /var/lib/mysql/mysql-bin.000023
-rw-r----- 1 mysql mysql 1.1G Dec 19 02:46 /var/lib/mysql/mysql-bin.000091
-rw-r----- 1 mysql mysql 1.6G Nov 3 22:43 /var/lib/mysql/mysql-bin.000083
-rw-r----- 1 mysql mysql 1.8G Nov 3 22:36 /var/lib/mysql/mysql-bin.000082
Description
The mysql-bin
files are a set of files that contain information about data modifications made by the MySQL server, such as table creation operations or changes to table data, which can be used for data recovery. By default, the binary logs are kept for 30 days. Active servers will generate large log files, which can quickly fill the available disk space. Reducing the log expiration time will reduce the number of log files generated.
Workaround
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Open
/etc/my.cnf
in your preferred text editor. - Add the following line in the [mysqld] section of the file.
binlog_expire_logs_seconds = $seconds
Please note that "$seconds" must be replaced with the number of seconds to keep the logs. If you were to set the expiration time to one day, you would set the value to86400
. - Save the changes and exit the text editor.
- Restart the mysqld service.
/usr/local/cpanel/scripts/restartsrv_mysql
Additional resources
MySQL 8.0 Reference Manual: 19.1.6.4 Binary Logging Options and Variables
MySQL 8.0 Reference Manual: 15.4.1.1 PURGE BINARY LOGS Statement
Comments
0 comments
Article is closed for comments.