Mariadb – Changing location of binlog prevents starting up

mariadb

I've copied data/binlog files between MariaDB (10.3) instances and wanted to change the location of data/log files on the new machine. I adjusted the paths in the my.cnf file. On start on the new machine, the mysqld continues to refer to the old locations, ignoring the paths specified in the my.cnf file – this obviously results in an error like so:

mysqld [ERROR] mysqld: File '<old-location>/mariadb-bin.000160' not found (Errcode: 2 "No such file or directory")
mysqld [ERROR] Failed to open log (file '<old-location>/mariadb-bin.000160', errno 2)
mysqld [ERROR] Could not open log file
mysqld [ERROR] Can't init tc log
mysqld [ERROR] Aborting'

I grepped and found that the ibdata1 file has a reference to the old path – is this something that needs to be updated with mysql CLI prior to the migration?

As far as I can tell, this is not the same as the problem described here: https://stackoverflow.com/questions/7660410/try-to-change-bin-log-directory-mysql-bin-index-not-found-errcode-13

The new instance continues to refer to the old path, despite the my.cnf change. Neither this is a permissions problem (like with apparmor or file ownership).

Best Answer

I finally figured it out: MariaDB keeps an "index" file, fortunately ASCII, that you need to edit: mariadb-bin.index located in the binlog directory (or wherever your log_bin_index configuration points at). This file lists all the binlog files with their full paths. This is unfortunate as the paths should be relative to the log_bin configuration setting. Example:

$ head mariadb-bin.index
/<binlog path>/mariadb-bin.000001
/<binlog path>/mariadb-bin.000002