主库ip 172.22.230.212
从库ip 172.22.230.213
数据库备份
mysqldump -uroot -p --databases xhjgame>xhjgame.sql
主库
>CREATE USER 'slave'@'172.22.230.213' IDENTIFIED BY '密码';
>GRANT REPLICATION SLAVE ON *.* TO 'slave'@'172.22.230.213';
>flush privileges;
> show master status
从库 注意两个值 mysql-bin.00058 和MASTER_LOG_POS
>CHANGE MASTER TO MASTER_HOST='172.22.230.212',
MASTER_USER='slave',
MASTER_PASSWORD='密码',
MASTER_LOG_FILE='mysql-bin.000587', MASTER_LOG_POS=0;
>start slave
>show slave status