码迷,mamicode.com
首页 > 数据库 > 详细

mysql 主从库同步

时间:2018-06-13 14:54:17      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:position   SQ   ica   password   start   dem   master   tin   server   

#主库修改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            

 

mysql 主从库同步

标签:position   SQ   ica   password   start   dem   master   tin   server   

原文地址:https://www.cnblogs.com/junko/p/9176863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!