mysql5.7使用gtid模式搭建主从复制架构

主库和从库搭建好之后,两者除了id基本一致
1.主库上创建repl账号

mysql> grant replication slave,replication client on *.* to 'repl'@'从库IP' identified by '123456';

2.从库执行以下命令

mysql> change master to master_host='192.168.199.201', \
    -> master_user='repl', \
    -> MASTER_PORT = port_num, \
    -> master_password='123456',master_auto_position=1;
# 启动
mysql>start slave;
# 查看
mysql> show slave status \G

你可能感兴趣的:(mysql,linux)