How to fix ERROR 1201: Could not initialize master info in MySQL
ERROR 1201 occurs in MySQL replication when the slave cannot initialize the master info structure, usually due to corrupted files or previous replication configuration. Reset the slave and reconfigure replication to fix this.
Quick fix
Fixes 1201
STOP SLAVE;- Stop the slave replication
- Reset the slave configuration
- Verify file permissions
- Reconfigure the master connection
STOP SLAVE;ERROR 1201: Could not initialize master info
What this error means
This error happens during MySQL replication setup when the slave server fails to initialize the master info structure, which stores critical replication metadata like the master host, port, username, and binary log position. The master info structure is essential for the slave to connect to and synchronize with the master database. When MySQL encounters issues reading, writing, or validating this structure—often due to corrupted master.info or relay-log.info files, permission problems, or conflicting previous configurations—it throws ERROR 1201 to prevent replication from starting in an inconsistent state.
Typical symptoms
- Replication fails to start or initialize during CHANGE MASTER TO command
- Error appears in MySQL error log when starting the MySQL service after a crash
- Previous replication configuration still exists on the slave
- master.info or relay-log.info files are 0 bytes or corrupted
- SHOW SLAVE STATUS command shows errors or missing values
Common causes
- Corrupted or 0-byte master.info or relay-log.info files from unclean shutdown or crash
- Incorrect file permissions on master.info, relay-log.info, or relay log files
- Previous replication configuration still exists and conflicts with new setup
- Corrupted relay log files preventing proper initialization
- Missing or invalid relay log files referenced in relay-log.info
How to fix "ERROR 1201: Could not initialize master info"
Connect to the slave MySQL server and stop replication before making any changes:
STOP SLAVE;If you are using MySQL 8.0.22 or later, use STOP REPLICA instead:
STOP REPLICA;Wait for any running SQL statements to complete.
Clear the existing master info and relay log files to remove corrupted data:
RESET SLAVE;For MySQL 8.0.22 or later:
RESET REPLICA;This command deletes the master.info file, relay-log.info file, and all relay log files. If you need to preserve relay logs for debugging, skip this step and manually delete the files from the MySQL data directory.
Ensure the MySQL user has proper read and write permissions on the data directory:
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod 750 /var/lib/mysqlReplace /var/lib/mysql with your actual MySQL data directory if different. This is critical for MySQL to create and access the new master.info file.
Establish a new replication connection with correct master parameters:
CHANGE MASTER TO
MASTER_HOST='your.master.host',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;For MySQL 8.0.23 or later, use CHANGE REPLICATION SOURCE instead:
CHANGE REPLICATION SOURCE TO
SOURCE_HOST='your.master.host',
SOURCE_USER='replication_user',
SOURCE_PASSWORD='password',
SOURCE_LOG_FILE='mysql-bin.000001',
SOURCE_LOG_POS=0;Replace the master host, credentials, and log file name with your actual values. Get the correct MASTER_LOG_FILE and MASTER_LOG_POS from the master using SHOW MASTER STATUS.
Start the slave with the new configuration:
START SLAVE;For MySQL 8.0.22 or later:
START REPLICA;Check that replication is running correctly:
SHOW SLAVE STATUS\GFor MySQL 8.0.22 or later:
SHOW REPLICA STATUS\GVerify that:
- Slave_IO_Running: Yes (or Replica_IO_Running: Yes)
- Slave_SQL_Running: Yes (or Replica_SQL_Running: Yes)
- Seconds_Behind_Master: 0 or a small number (not NULL)
If either running status is "No", check the error output and consult the MySQL error log.
Advanced notes
If RESET SLAVE alone does not resolve the issue, you may need to manually delete the master.info and relay-log.info files while MySQL is stopped. Locate these files in your MySQL data directory (often /var/lib/mysql) and delete them before restarting MySQL. Some setups use relay-log-recovery, which can help automatically recover from relay log corruption—check your my.cnf for relay-log-recovery=1. In multi-threaded slave setups using parallel SQL threads (slave_parallel_workers), also check for and delete worker.info files. After a crash or unclean shutdown, you may also see "Failed to open the relay log" or similar messages in the error log. These typically resolve once the master.info is successfully reinitialized. If replication remains stuck, examine the full error log for additional context—ERROR 1201 can mask underlying issues like corrupted binary logs on the master or network connectivity problems.
Frequently asked questions
- What does "1201" mean?
- This error happens during MySQL replication setup when the slave server fails to initialize the master info structure, which stores critical replication metadata like the master host, port, username, and binary log position. The master info structure is essential for the slave to connect to and synchronize with the master database. info files, permission problems, or conflicting previous configurations—it throws ERROR 1201 to prevent replication from starting in an inconsistent state.
- How do I fix "1201"?
- ERROR 1201 occurs in MySQL replication when the slave cannot initialize the master info structure, usually due to corrupted files or previous replication configuration. Reset the slave and reconfigure replication to fix this.
- What causes "1201"?
- Corrupted or 0-byte master.info or relay-log.info files from unclean shutdown or crash Incorrect file permissions on master.info, relay-log.info, or relay log files Previous replication configuration still exists and conflicts with new setup
- Is the "1201" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚MySQL Official Documentation
- 📖MySQL Error Reference - Error 1201(Official Docs)
- 📖MySQL Replication Troubleshooting Guide(Official Docs)