Mysql 主从搭建记录

Mysql 主从搭建

主库

1、配置文件路径:/etc/my.conf
2、添加配置:
server-id=1
log-bin=mysql-bin
sync-binlog=1
binlog-do-db=master
expire-logs-days=7
show_compatibility_56=on
binlog-ignore-db=information_schema
binlog-ignore-db=performation_schema
binlog-ignore-db=sys
注意log-bin要在server-id后面,并且同时存在
3、创建同步数据账号并赋予权限
create user ‘jiu_bk’@’%’ identified by ‘1qaz2wsx’;
grant replication slave on . to ‘jiu_bk’@’%’ identified by ‘1qaz2wsx’;
4、 查看主库信息并用于从库创建同步所用,主要是log-bin日志文件和偏移位置
show master status\G

从库

1、配置文件:/etc/my.conf
2、增加配置
server_id=2
master_info_repository=TABLE
relay_log_info_repository=TABLE
3、配置从库连接的主库
change master to
master_host=‘10.1.1.100’,
master_user=‘jiu_bk’,
master_password=‘1qaz2wsx’,
master_log_file=‘mysql-bin.000001’,
master_log_pos=1537;
4、查看从库信息
show slave status \G

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值