How to Fix MySQL Error 1200 (ER_BAD_SLAVE)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mysql error 1200 when a node tries to run replica commands without primary source details. Fix it by adding the primary host details in your server settings or running the source setup command. In the MySQL engine, this failure maps to symbol ER_BAD_SLAVE and SQLSTATE HY000. The database message states that the server is not set up as a slave. It tells you to fix the config file or run the master setup command. This issue blocks data sync between your primary database and your read node

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You see mysql error 1200 when a node tries to run replica commands without primary source details. Fix it by adding the primary host details in your server settings or running the source setup command.

In the MySQL engine, this failure maps to symbol ER_BAD_SLAVE and SQLSTATE HY000. The database message states that the server is not set up as a slave. It tells you to fix the config file or run the master setup command. This issue blocks data sync between your primary database and your read nodes. Teams often hit this wall during cluster builds, node rebuilds, or manual failover tests.

What causes mysql error 1200 in your cluster

A replica node needs clear instructions before it can pull data from a primary server. It must know the primary host address, port, user login, and log position. When you tell the database to start replication without these facts, the engine stops. It throws error 1200 to tell you the replica metadata is missing or broken.

Several common mistakes cause this missing state in a database cluster. A team member might run a replica start command on the wrong server by mistake. For example, someone might log in to a standalone test node or the primary database itself. Since that node has no primary source set up, the engine rejects the command right away.

Another frequent trigger is an incomplete node build. When you spin up a new read node, automated scripts might fail midway. If the script skips the step that defines the primary host, the node stays blank. You will also see this error after a full replica reset that wipes out saved source details.

Disk issues and bad server settings can also cause this failure. If the server lacks a unique ID in its main settings file, replication cannot start. In other cases, the local files that store primary log positions get wiped during a crash. When the database boots back up, it forgets its role as a replica.

How to check the replica state safely

Before you change any settings, check which server you are logged into. Many outages happen when engineers run replica fixes on a live primary node. Check the server hostname and read its current role status first. Make sure this specific machine is meant to be a read replica.

MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Next, check the current replica status output on the affected node. If the output is empty, the database has no record of a primary source. Check the server error log to see why those details are missing. The log will show if a past reset command or file read error wiped the state.

Also verify that the node has a unique server ID set up. Every node in a replication group must have its own distinct number. If two nodes share a number, or if the number is missing, sync will fail.

How to fix the error in production

To fix the error, give the replica the exact network and log details for the primary server. First, make sure you have a dedicated replication user on the primary database. Do not use the main admin account for node sync. Create a role that only has permission to read binary logs from the source.

Next, find the exact binary log file name and position on the primary node. If your cluster uses global transaction IDs, check that both nodes have that mode turned on. Then, run the source setup command on the replica to point it at the primary host. Pass in the host address, replication user, password, and log coordinates.

Once you apply those details, tell the replica threads to start running. Check the replica status again right away. Look at the input and SQL thread fields to confirm both show a running state. Watch the lag counter until the replica catches up with the primary node. Keep admin permissions tight during this whole fix so daily app users cannot alter cluster state.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

Does mysql error 1200 mean my database lost data?

No, this error only means the node does not know where to pull updates from. Your existing data on the primary server and the replica remains untouched.

Can I fix this error without restarting the MySQL service?

Yes, you can set the primary host details and start the replica threads while the server runs. You only need a restart if you must change base settings file values.

Why did error 1200 appear after I ran a replica reset command?

A full replica reset command clears the saved primary host and log coordinates from memory and disk. You must enter the primary connection details again before you start the replica.

The query runs. The emails stay hidden.