To set up the slave to communicate with the master for replication, configure the slave with the necessary connection information. To do this, execute the following statement on the slave, replacing the option values with the actual values relevant to your system:
mysql> CHANGE MASTER TO -> MASTER_HOST='master_host_name', -> MASTER_USER='replication_user_name', -> MASTER_PASSWORD='replication_password', -> MASTER_LOG_FILE='recorded_log_file_name', -> MASTER_LOG_POS=recorded_log_position;
Replication cannot use Unix socket files. You must be able to connect to the master MySQL server using TCP/IP.
CHANGE MASTER TO statement
has other options as well. For example, it is possible to set up
secure replication using SSL. For a full list of options, and
information about the maximum permissible length for the
string-valued options, see CHANGE MASTER TO Syntax.
As noted in
Section 2.2.3, “Creating a User for Replication”, if you
are not using a secure connection and the user account named
MASTER_USER option authenticates
caching_sha2_password plugin (the
default from MySQL 8.0), you must specify the
GET_MASTER_PUBLIC_KEY option in the
CHANGE MASTER TO statement to enable RSA
key pair-based password exchange.