MySQL Shell 9.3
When you are working with a single-primary InnoDB Cluster or an InnoDB ReplicaSet, you need to connect to the primary instance for administration tasks so that configuration changes are written to the metadata. To find the current primary you can:
Use the --redirect-primary
option at MySQL Shell start up to ensure that the target
server is part of an InnoDB Cluster or InnoDB ReplicaSet.
If the target instance is not the primary, MySQL Shell finds
the primary and connects to it.
Use the
shell.connectToPrimary([
operation,
which checks whether the target instance belongs to a cluster
or ReplicaSet. If so, MySQL Shell opens a new session to the
primary, sets the active global MySQL Shell session to the
established session and returns it.
instance
,
password
])
If an instance
is not provided, the
operation attempts to use the active global MySQL Shell
session. If an instance
is not
provided and there is no active global MySQL Shell session,
an exception is thrown. If the target instance does not belong
to a cluster or ReplicaSet the operation fails with an error.
Use the status operation, find the primary in the result, and manually connect to that instance.