Planned primary switchover in InnoDB Cluster
MySQLInnoDB ClusterCommand
# Shell: planned switchover
mysqlsh icadmin@db1:3306 -- cluster set-primary-instance db2:3306
-- SQL alternative: target member's server_uuid, 30 s timeout for open transactions
SELECT MEMBER_HOST, MEMBER_ID, MEMBER_ROLE FROM performance_schema.replication_group_members;
SELECT group_replication_set_as_primary('3f06e651-c356-11f1-8aac-927a9034ef99', 30);What it does
Moves the primary role to another member in a controlled way in single-primary mode; the old primary becomes super_read_only, the new one applies its backlog and opens for writes. MySQL Router learns the new primary automatically.
When to use it
Before maintenance, OS patching or upgrading the primary, and for hardware moves.
Caution
Open transactions on the old primary are killed when the timeout expires; without a timeout the switch waits for them and takes longer. If the application does not connect through Router, you must redirect it yourself. With BEFORE_ON_PRIMARY_FAILOVER writes wait until the new primary has drained its backlog; confirm apply_queue is empty in cluster status first. In InnoDB Cluster prefer the Shell command; it stays consistent with the metadata.