mysql 主从库同步

Posted 亡羊补牢

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 主从库同步相关的知识,希望对你有一定的参考价值。

#主库修改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:ProgramDataMySQLMySQL Server 5.7Datamaster.info    0        Slave has read all relay log; waiting for more updates    86400                                0            

 

以上是关于mysql 主从库同步的主要内容,如果未能解决你的问题,请参考以下文章

mysql 主从库同步

Mysql主从同步异常处理

Mysql主从同步异常处理

部署mysql主从同步

mysql6.5主从库同步

mysql主从同步搭建和故障排除