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.
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.
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.
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.
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL