当前位置:网站首页>mysql主从同步
mysql主从同步
2022-06-30 19:20:00 【努力学习,努力爱你!】
mysql安装 需要安装两个
https://blog.csdn.net/weixin_45247019/article/details/124748512
主库配置
cd /mydata/mysql/conf
#修改文件
vi my.cnf
my.cnf
[mysqld]
# 开启二进制日志并指定日志名前缀
log-bin=mysql-bin
# 设置唯一库ID
server-id=1
重启服务
service mysql restart
添加用户(从主连接使用)
# 登录mysql
mysql -u root -p
# 创建用户repl
mysql> CREATE USER 'replymeee'@'%' IDENTIFIED WITH mysql_native_password BY 'replymeee';
# 授予用户repl从库相关权限
mysql> GRANT REPLICATION SLAVE ON *.* TO 'replymeee'@'%';
# 刷新权限
mysql> flush privileges;
获取主库 日志文件和位置
mysql> SHOW MASTER STATUS;

从库配置
cd /mydata/mysql/conf
#修改文件
vi my.cnf
my.cnf
[mysqld]
# 开启二进制日志并指定日志名前缀
log-bin=mysql-bin
# 设置唯一库ID
server-id=2
重启服务
service mysql restart
连接主库
# 登录mysql
mysql -u root -p
# 设置主库参数
mysql> CHANGE MASTER TO
MASTER_HOST='xxx.xxx.xxx.xxx', #主库ip
MASTER_USER='replymeee', # 用户
MASTER_PASSWORD='replymeee', #密码
MASTER_LOG_FILE='binlog.000006', #二进制文件
MASTER_LOG_POS=856; #二进制位置
开启同步
start slave;
#查看状态
show slave status\G;

作者声明
如有问题,欢迎指正!
边栏推荐
猜你喜欢

Makefile笔记(一文学会Makefile)

腾讯会议应用市场正式上线,首批入驻超20款应用

VR全景中特效是如何编辑的?细节功能如何展示?

正则系列之字符类

Why do more and more people choose cloud rendering?

测试必备工具 —— Postman实战教程

Tencent conference application market was officially launched, with more than 20 applications in the first batch

JVM FAQs

RP原型资源分享-购物类App

S7-1500 PLC之间进行TCP通信的具体方法和步骤详解(图文)
随机推荐
【已解决】抖音如何取消关注已注销的账户
力扣------统计包含给定前缀的字符串
Why do more and more people choose cloud rendering?
Task04: set operation - addition and subtraction of tables, join, etc. - learning notes of Tianchi Longzhu project SQL training camp
VR全景拍摄为什么要加盟?巧借资源实现共赢
6-1漏洞利用-FTP漏洞利用
毕业季职场人
Tencent conference application market was officially launched, with more than 20 applications in the first batch
dataloader 源码_DataLoader
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
What securities dealers recommend? In addition, is it safe to open a mobile account?
[solved] how does Tiktok cancel paying attention to the cancelled account
Promise从认识到使用
线上线下双结合,VR全景是家具线上转型好方法!
Go language learning tutorial (10)
网易云签到可抽奖?那一年我能签到365天。不信?你看。
说实话ThreadLocal真不是啥高级的东西
MQ advantages and disadvantages (2022.5.2-5.8)
4.3-inch touch screen 12 channel control port programmable network central control supports mutual backup of 5 central control hosts
Force deduction ----- count the string containing the given prefix