Since binary logs occupy more space, and sometimes you may wish to change the location of binary logs, the following procedure helps. Changing the log_bin
alone is not sufficient, you have to move all the binary logs and update the index file with the new location. The mysqlbinlogmove
utility eases your work by automating those tasks.
MySQL Utilities should be installed for using the mysqlbinlogmove
script. Refer to Chapter 1, MySQL 8.0 – Installing and Upgrading, for installation steps.
- Stop the MySQL server:
shell> sudo systemctl stop mysql
- Start the
mysqlbinlogmove
utility. If you want to change the binary logs from/data/mysql/binlogs
to/binlogs
, the following command should be used. If your base name is not default, you have to mention your base name through the--bin-log-base name
option:
shell> sudo mysqlbinlogmove --bin-log-base name=server1 --binlog-dir=/data/mysql/binlogs /binlogs
#
# Moving bin-log files...
# - server1.000001
# - server1...