mysql S > CREATE USER ’ replica_user ’@’ replica_host ’ -> IDENTIFIED BY ’ replica_password ’; mysql S > GRANT REPLICATION SLAVE ON *.* -> TO ’ replica_user ’@’ replica_host ’; 

In the previous statement, replica_user  is the replication account user name, replica_host  is the host name or IP address of the replica, and replica_password  is the password to assign to this account. 

For example, to create a replica user account with the name myreplica , logging in from the host named replica-host , and using the password 53cr37 , use the following CREATE USER  and GRANT statements: 

mysql S > CREATE USER ’myreplica’@’replica-host’ -> IDENTIFIED BY ’53cr37’; mysql S > GRANT REPLICATION SLAVE ON *.* -> TO ’myreplica’@’replica-host’; 

For security reasons, it is preferable to use a unique user account—not employed for any other purpose —for the replication account. 

3. Set up the replica to use the source. Using the mysql  client, this can be accomplished with the CHANGE REPLICATION SOURCE TO  statement (beginning with MySQL 8.0.23) or CHANGE MASTER TO  statement (before MySQL 8.0.23): 

mysql R > CHANGE MASTER TO -> MASTER_HOST=’ source_host ’, -> MASTER_PORT= source_port , -> MASTER_USER=’ replica_user ’, -> MASTER_PASSWORD=’ replica_password ’; 

Beginning with MySQL 8.0.23, you can also use the following statement: 

mysql R > CHANGE REPLICATION SOURCE TO -> SOURCE_HOST=’ source_host ’, -> SOURCE_PORT= source_port , -> SOURCE_USER=’ replica_user ’, -> SOURCE_PASSWORD=’ replica_password ’; 

In the previous statement, source_host  is the host name or IP address of the replication source, source_port  is the port for the replica to use when connecting to the source, replica_user  is the user name set up for the replica on the source, and replica_password  is the password set for that user account in the previous step. 

For example, to tell the replica to use the MySQL server whose host name is rep-source  with the replication account created in the previous step, use the following statement: 

mysql R > CHANGE MASTER TO -> MASTER_HOST=’rep-source’, -> MASTER_PORT=3306, -> MASTER_USER=’myreplica’, -> MASTER_PASSWORD=’53cr37’; 

Beginning with MySQL 8.0.23, you can also use the following statement: 

mysql R > CHANGE REPLICATION SOURCE TO -> SOURCE_HOST=’rep-source’, 

