主库配置
server_id=1
read-only=0
replicate-do-db=mydata
log-bin=mysql-bin
主库权限设置
grant replication slave on *.* to backup@192.168.1.222 identified by ‘123’
show master status
从库配置:
server_id=2
read-only=1
replicate-do-db=mydata
log-bin=mysql-bin
change master to MASTER_HOST=‘172.20.42.224‘, MASTER_USER=‘backup‘,MASTER_PASSWORD=‘password‘, MASTER_LOG_FILE=‘mysql-bin.000085‘,MASTER_LOG_POS=839, master_connect_retry=60,MASTER_PORT=3307
stop SLAVE
START slave
SHOW SLAVE status
这三个状态 slave_IO_state、slave_IO_running、slave_SQL_running 是yes,配置成功。
原文:https://www.cnblogs.com/alantop/p/11605233.html