# 登录 MySQL mysql -uroot -p mysql> create user 'sync'@'10.180.210.19' identified by 'Sync-123456'; # 创建用户 sync,设置密码 Sync-123456,并允许备库 10.180.210.19 登录 mysql> flush privileges; # 刷新权限 mysql> grant replication slave on *.* to 'sync'@'10.180.210.19' identified by 'Sync-123456' with grant option; # 赋予用户 sync 进行 replication slave 到备库 10.180.210.19 的权限
# 查询 master 状态 mysql> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | master-bin.000001 | 121040 | mindoc_db | mysql | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
设置主库信息
备节点
在备节点上设置主库信息
1 2 3 4 5 6 7 8 9
mysql -uroot -p
mysql> change master to master_host='10.180.249.18', master_port=3306, master_user='sync', master_password='Sync-123456', master_log_file='master-bin.000001', master_log_pos=121040;