MySQL ERROR 1200 occurs when you try to execute replication commands on a server that hasn't been configured as a slave. This is typically fixed by running CHANGE MASTER TO with the correct replication settings or by verifying your configuration file.
MySQL ERROR 1200 (ER_BAD_SLAVE) means the server is not properly configured to act as a slave in a replication setup. In MySQL replication, a master server sends changes to slave servers that replicate the data. This error occurs when you attempt to execute slave-related commands (like START SLAVE or SHOW SLAVE STATUS) on a server that has not been configured with the necessary replication parameters. The error message tells you to either fix your configuration file (my.cnf or my.ini) or use the CHANGE MASTER TO command to configure the slave properly.
First, verify that the server has a valid, unique server ID. Run this command:
SHOW VARIABLES LIKE 'server_id';The result should show a non-zero value. If it shows 0 or is missing, the server cannot participate in replication. Each server in a replication topology must have a unique server_id.
Edit your MySQL configuration file (/etc/my.cnf or /etc/mysql/my.cnf on Linux, or C:\\ProgramData\\MySQL\\MySQL Server\\my.ini on Windows) and ensure it contains the required replication settings:
[mysqld]
server-id=2
log_bin=mysql-bin
relay-log=mysql-relay-bin
read-only=1Key settings explained:
- server-id=2 - Unique ID for this slave (must be different from master and other slaves)
- log_bin=mysql-bin - Enable binary logging (required for replication)
- relay-log=mysql-relay-bin - Relay log for received changes
- read-only=1 - Optional: makes slave read-only to prevent accidental writes
After editing, save the file and restart MySQL:
# Linux/macOS
sudo systemctl restart mysql
# Or if using a Docker container:
docker restart <container_name>On the slave server, run the CHANGE MASTER TO command with the correct master connection details. You'll need information from the master server:
First, on the MASTER server, run:
SHOW MASTER STATUS;This shows:
- File (binary log file name)
- Position (log position)
Then on the SLAVE server, run:
CHANGE MASTER TO
MASTER_HOST='192.168.1.100',
MASTER_USER='replication_user',
MASTER_PASSWORD='your_password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=154;Replace with your actual values:
- MASTER_HOST - IP address or hostname of the master server
- MASTER_USER - Username of the replication user on the master
- MASTER_PASSWORD - Password for that user
- MASTER_LOG_FILE - From SHOW MASTER STATUS output
- MASTER_LOG_POS - From SHOW MASTER STATUS output
After configuring the slave, start replication:
START SLAVE;Then check the status:
SHOW SLAVE STATUS\GLook for these critical fields:
- Slave_IO_Running: Yes - Network thread is connected to master
- Slave_SQL_Running: Yes - SQL thread is executing master's changes
- Last_Error: (empty) - No replication errors
- Seconds_Behind_Master: 0 - Slave is caught up with master
If both IO and SQL threads show "Yes" and there are no errors, replication is working correctly.
If CHANGE MASTER TO returns an error:
1. Empty MASTER_HOST error: Do not set MASTER_HOST to an empty string. Either provide a valid host or use CHANGE MASTER TO ... MASTER_HOST='actual_host'.
2. Duplicate server-id: Ensure no other server in your replication topology has the same server_id. Each server must be unique.
3. File does not exist: Verify the MASTER_LOG_FILE exists on the master. Run SHOW BINARY LOGS; on the master to list available logs.
4. Invalid credentials: Test the replication user credentials by connecting from the slave:
mysql -h 192.168.1.100 -u replication_user -p5. Network connectivity: Ensure the slave can reach the master on port 3306:
telnet 192.168.1.100 3306In MySQL 8.0.33 and later, the terminology changed from "slave" to "replica" for inclusive language. The error symbol changed from ER_BAD_SLAVE to ER_BAD_REPLICA, and commands like START SLAVE changed to START REPLICA. CHANGE MASTER TO became CHANGE REPLICATION SOURCE TO. The functionality remains the same, but use the newer syntax for MySQL 8.0.33+.
For setups with multiple slaves, each slave must have a unique server_id. When using RESET SLAVE ALL (which removes all replication information), you must reconfigure the slave with CHANGE MASTER TO again before replication can resume.
In production environments, always set up a dedicated replication user with minimal privileges (REPLICATION SLAVE, REPLICATION CLIENT) rather than using the root account.
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