#主库修改my.ini [mysqld] server-id=2 log-bin=mysql-bin binlog-do-db=demo #从库修改my.ini [mysqld] server-id=3 replicate-do-db=demo --配置完成后重启主从库 #主库为从库添加用户 grant replication slave,reload,super on *.* to slave@14.23.88.110 identified by ‘123456‘; show master status; 查询主机file/postin +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000004 | 722 | demo | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.01 sec) #从库 检测是否能够连接上主库,保证主从通讯 stop slave; 关闭从机同步连接 change master to master_host=‘14.23.88.111‘,Master_Port=4569,master_user=‘slave‘,master_password=‘123456‘, master_log_file=‘mysql-bin.000004‘,master_log_pos=722; start slave; --启动从机步连接 show slave status --查看状态 Waiting for master to send event 14.23.88.110 slave 4569 60 mysql-bin.000004 154 DELL-PC-relay-bin.000004 367 mysql-bin.000004 Yes Yes demo 0 0 154 623 None 0 No 0 No 0 0 2 ebd6ae04-6e14-11e8-b39c-444553544f53 C:\ProgramData\MySQL\MySQL Server 5.7\Data\master.info 0 Slave has read all relay log; waiting for more updates 86400 0
原文地址:https://www.cnblogs.com/junko/p/9176863.html
时间: 2024-11-07 06:47:12