Name

SHOW SLAVE HOSTS

Synopsis

SHOW SLAVE HOSTS

This statement displays a list of slave servers for the master server. Slaves must be started with the --report-host=slave option in order to be shown. Here is an example:

SHOW SLAVE HOSTS;

+------------+-----------+------+-----------+
| Server_id  | Host      | Port | Master_id |
+------------+-----------+------+-----------+
|          2 | slave2    | 3306 |         1 |
|          3 | slave3    | 3306 |         1 |
+------------+-----------+------+-----------+

Four fields are in the results:

Server_id

The server identification number for the slave server, which is set by the --server-id option (preferably in the slave’s options file).

Host

The hostname of the slave server, which is set by the --report-host option on the slave.

Port

The port on which the slave is listening for replication. This defaults to 3306, but can be set with the CHANGE MASTER TO statement, described earlier in this chapter.

Master_id

The server identification number of the master. It’s set on the master with --server-id and conversely on the slave with the CHANGE MASTER TO statement.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.