MySQL fatal error 1236

MySQL error message when attempting to start a replication slave:

Got fatal error 1236: ‘Could not find first log file name in binary log index file’ from master when reading data from binary log

I banged my head against a wall for a short period of time trying resolve this one. The resolution is easy, but I didn’t find it in my searching. Hopefully this will allow someone to move forward more quickly than I did, providing I am not the only one that didn’t immediately realize what was going on. The full error reads something like:

060903 11:01:58 [Note] Slave SQL thread initialized, starting replication in log '/var/mysql/logs/mysql-log.000125' at position 97277001, relay log './slave-relay-bin.000001' position: 4
060903 11:01:58 [Note] Slave I/O thread: connected to master 'slave@master:3306', replication started in log '/var/mysql/logs/mysql-log.000125' at position 97277001
060903 11:01:58 [ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno=1236)
060903 11:01:58 [ERROR] Got fatal error 1236: 'Could not find first log file name in binary log index file' from master when reading data from binary log
060903 11:01:58 [Note] Slave I/O thread exiting, read up to log '/var/mysql/logs/mysql-log.000125', position 97277001

The slave was being started from an InnoDB Hot Backup created on the master. After restoring the backup and starting up MySQL, the following binlog position was reported:

InnoDB: Last MySQL binlog file position 0 97277001, file name /var/mysql/logs/mysql-log.000125

which suggests the change master statement:

CHANGE MASTER TO
MASTER_HOST='master',
MASTER_USER='slave',
MASTER_LOG_FILE='/var/mysql/logs/mysql-log.000125',
MASTER_LOG_POS=97277001;

However, the full path to the log file is what causes the ‘Could not find first log file name in binary log index file’ error. MySQL looks for the log file in the defined log directory, /var/mysql/logs in this case. Simply adjusting the change master statement:

CHANGE MASTER TO
MASTER_HOST='master',
MASTER_USER='slave',
MASTER_LOG_FILE='mysql-log.000125',
MASTER_LOG_POS=97277001;

results in:

060903 11:15:16 [Note] Slave SQL thread initialized, starting replication in log 'mysql-log.000125' at position 97277001, relay log './slave-relay-bin.000001' position: 4
060903 11:15:16 [Note] Slave I/O thread: connected to master 'slave@master:3306', replication started in log 'mysql-log.000125' at position 97277001

And we’re replicating. Maybe if I had more occasion to bring up new MySQL replication slaves, this would have been obvious.