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

mysql 配置主从

时间:2018-01-11 15:56:15      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:同步   hang   创建   star   stat   127.0.0.1   启动   body   roo   

1,在主服务器my.ini中添加:
    server-id=1   //给数据库服务的唯一标识,一般为大家设置服务器Ip的末尾号
    log-bin=master-bin
    log-bin-index=master-bin.index
2,启动主服务器;
3,执行show master status;查看主服务器状态;
4,复制当前主服务器中的数据库内容;
5,在从服务器中创建主服务器数据库;
6,在从服务器my.ini中添加:
    server-id=2
    relay-log-index=slave-relay-bin.index
    relay-log=slave-relay-bin
7,启动从服务器;
8,在从服务中执行:
    change master to master_host=‘127.0.0.1‘, //Master 服务器Ip
    master_port=3306,
    master_user=‘root‘,
    master_password=‘admin‘,
    master_log_file=‘master-bin.000001‘,//Master服务器产生的日志
    master_log_pos=0;
9,启动从服务:start slave;
10,在主服务器中添加一条数据,查看在从服务器中是否同步成功;

mysql 配置主从

标签:同步   hang   创建   star   stat   127.0.0.1   启动   body   roo   

原文地址:https://www.cnblogs.com/ericli-ericli/p/8267514.html

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