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

mysql master slave搭建

时间:2015-11-03 12:29:03      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

1、

 

2、配置master

修改/etc/my.cnf增加

[mysqld]
log-bin = master-bin
log-bin-index = master-bin.index
server-id = 1

  


3、master创建一个复制用户

CREATE USER repl_user;

GRANT REPLICATION SLAVE ON *.* TO repl_user IDENTIFIED BY ‘123456‘;

  

重启master

 

4、配置slave

修改/etc/my.cnf增加

[mysqld]
server-id = 2
relay-log-index = slave-relay-bin.index
relay-log slave-relay-bin

  

重启slave


5、连接master和slave

CHANGER MASTER TO
MASTER_HOST = ‘master-1‘,
MASTER_PORT = 3306,
MASTER_USER = ‘repl_user‘,
MASTER_PASSWORD = ‘123456‘;

START SLAVE;

  

 

mysql master slave搭建

标签:

原文地址:http://www.cnblogs.com/huanhuanang/p/4932532.html

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