温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

说说MySQL 主从复制吧

发布时间:2020-08-07 18:13:55 阅读:173 作者:aqiandao 栏目:MySQL数据库
亿速云mysql数据库,读写分离,安全稳定,弹性扩容,低至0.3元/天!! 点击查看>>

环境:win10(就配置主从来说linux和windows差别不大),MySQL-5.7.16

1.首先要两个MySQL实例,我这里分别是3307,3308,其中3307作为master,3308作为slave

2.修改master实例的配置my.ini,增加两行:

Ini代码 

 说说MySQL 主从复制吧

  1. [mysqld]  
  2. log_bin = mysql-bin  
  3. server_id = 3307    #server_id 随意但必须唯一  

3.修改slave实例的配置my.ini,增加两行:

Ini代码 

 说说MySQL 主从复制吧

  1. [mysqld]  
  2. log_bin = mysql-bin  
  3. server_id = 3308    #server_id 随意但必须唯一  

 4.启动master,登陆后,创建用户replicant,并授权

说说MySQL 主从复制吧
 授权后执行flush privileges; 我这里忘记截了.

5.查看master状态,前两项要记住:

说说MySQL 主从复制吧
 
 到这里master就完了,在配置完slave之前最好就不要在动master,因为有可能会改变Position。

6.启动slave,登陆后,执行:

说说MySQL 主从复制吧
 

7.查看slave status:


说说MySQL 主从复制吧
 其中Slave_IORunning和Slave_SQL_Running均为YES才说明成功.

这里就算配置完成了。

测试

在master上新建库,表,插入数据:


说说MySQL 主从复制吧

在slave 上select数据:现货重油


说说MySQL 主从复制吧

  http://www.wangchao.net.cn/hi/detail_232429.html

  http://www.wangchao.net.cn/hi/detail_232433.html

  http://www.wangchao.net.cn/hi/detail_232437.html

  http://www.wangchao.net.cn/hi/detail_232438.html

  http://www.wangchao.net.cn/hi/detail_232441.html

  http://www.365128.com/user/myx2/39.html

  http://www.365128.com/user/myx2/40.html

  http://www.365128.com/user/myx2/41.html

  http://www.365128.com/user/myx2/42.html

  http://www.365128.com/user/myx2/43.html

  http://www.365128.com/user/myx2/44.html

  http://www.365128.com/user/myx2/45.html

  http://www.365128.com/user/myx2/46.html

  http://www.365128.com/user/myx2/47.html

  http://www.365128.com/user/myx2/48.html

  http://site.leshou.com/s/33563826.html

  http://site.leshou.com/s/33563870.html

  http://site.leshou.com/s/33563896.html

  http://site.leshou.com/s/33563950.html

  http://site.leshou.com/s/33564004.html

  http://site.leshou.com/s/33564069.html

  http://site.leshou.com/s/33564112.html

  http://site.leshou.com/s/33564134.html

  http://site.leshou.com/s/33564165.html

  http://site.leshou.com/s/33564197.html

亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:http://blog.itpub.net/30065054/viewspace-2126747/

AI

开发者交流群×