Master-Slave Replication

The master logs all changes (binary log), which the slave reads and replays.

# On master
[mysqld]
server-id=1
log-bin=mysql-bin

# On slave
[mysqld]
server-id=2
relay-log=slave-relay-bin

Setup

CHANGE MASTER TO 
MASTER_HOST='master_ip', 
MASTER_USER='replica', 
MASTER_PASSWORD='pass', 
MASTER_LOG_FILE='mysql-bin.000001', 
MASTER_LOG_POS=120;
START SLAVE;

GTID Replication

GTIDs are unique IDs for transactions that simplify failover.

SET GLOBAL enforce-gtid-consistency=ON;
SET GLOBAL gtid-mode=ON;