当前位置:网站首页>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;
作者声明
如有问题,欢迎指正!
边栏推荐
- Growth summer challenge is coming, exclusive community welfare is coming ~ get CSDN customized T-shirt for free
- 十分之坑,tar命令解压文件的时候竟然不能解析英文括号“()”
- 1. 爬虫之Beautifulsoup解析库&在线解析图片验证码
- 实现各种效果和功能的按钮,读这篇文章就够了
- 项目配置了eslint,编辑器没有关闭eslint功能的情况下,eslint没有生效
- Smarter! Airiot accelerates the upgrading of energy conservation and emission reduction in the coal industry
- 【LeetCode】【SQL】刷题笔记
- PS2手柄-1「建议收藏」
- Code shoe set - mt3435 · assignment - bipartite graph problem - Graphic explanation
- Wechat applets - basics takes you to understand the life cycle of applets (2)
猜你喜欢
盘点华为云GaussDB(for Redis)六大秒级能力
1. 爬虫之Beautifulsoup解析库&在线解析图片验证码
mysql统计账单信息(上):mysql安装及客户端DBeaver连接使用
This morning, investors began to travel collectively
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
6-1漏洞利用-FTP漏洞利用
FH6908A负极关断同步整流模拟低压降二极管控制IC芯片TSOT23-6超低功耗整流器 1w功耗 <100uA静态 替代MP6908
A necessary tool for testing -- postman practical tutorial
条件编译
Tencent conference application market was officially launched, with more than 20 applications in the first batch
随机推荐
毕业季职场人
Why must a digital transformation strategy include continuous testing?
力扣------统计包含给定前缀的字符串
SSM整合流程(整合配置、功能模块开发、接口测试)
The former king of fruit juice sold for 1.6 billion yuan
杭州炒股开户选择手机办理安全吗?
KubeVela 1.4:让应用交付更安全、上手更简单、过程更透明
十分之坑,tar命令解压文件的时候竟然不能解析英文括号“()”
MQ advantages and disadvantages (2022.5.2-5.8)
将 EMQX Cloud 数据通过公网桥接到 AWS IoT
QQmlApplicationEngine failed to load component qrc:/main.qml:-1 No such file or directory
Connect to lab server
8 - 函数
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
The prospectus of pelt medical was "invalid" for the second time in the Hong Kong stock exchange, and the listing plan was substantially delayed
Understanding of event queue, micro task and macro task and interview questions
Is it safe to open an account for mobile phone stock trading!?
说实话ThreadLocal真不是啥高级的东西
Go language learning tutorial (13)
SM2246EN+闪迪15131