Troubleshooting·MySQL
MySQL Replica Write Protection
A fresh replica is not read-only. A write to it succeeds, diverges the data and plants a transaction the source has never heard of - and super_read_only is the one-line prevention.
Replication Guide 29 of 45 Intermediate
- OSUbuntu 26.04 LTS
- MySQL8.4.10-0ubuntu0.26.04.1
- ReplicationGTID, ROW format, auto-position
- TimeAbout 15 min
read_only alone does not stop users with the SUPER privilege - which includes root, and therefore most people connecting to fix something. super_read_only is the one that means it.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
| db-b01 | 192.168.0.82 | Ubuntu 26.04 LTS | Standby / Replica / Replica Set Member 2 | 2 Core | 4 GB | 50 GB |
This guide includes
Use this immediately after a replica starts working. This matters because a fresh replica accepts writes - and one local write puts a transaction into its GTID history that the source has never seen.
- discovering the replica accepts writes, with both variables sitting at 0
- seeing what that write did to the GTID history on both hosts
- closing the door with
super_read_only, which setsread_onlyas well - confirming replication still works through it
Before you start
- A running replica - see the previous guide.
-
Discover that the replica accepts writes
-
See what that write did to the GTID history
-
Close the door
-
Confirm replication still works through it