当前位置:网站首页>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;

作者声明
如有问题,欢迎指正!
边栏推荐
- Advanced skills of testers: a guide to the application of unit test reports
- Simple usage of LinkedList (2022.6.13-6.19)
- Configure server environment
- 网易云签到可抽奖?那一年我能签到365天。不信?你看。
- Growth summer challenge is coming, exclusive community welfare is coming ~ get CSDN customized T-shirt for free
- Safe holidays without holidays, VR traffic makes children travel safely | Guangzhou Sinovel viewpoint
- 广州炒股开户选择手机办理安全吗?
- 4.3寸触控屏12路控制端口可编程网络中控支持5台中控主机相互备份
- Redis beginner to master 01
- Lombok
猜你喜欢

笔记软件的历史、选择策略以及深度评测

Smarter! Airiot accelerates the upgrading of energy conservation and emission reduction in the coal industry

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)

Wechat applets - basics takes you to understand the life cycle of applets (2)

Taiwan SSS Xinchuang sss1700 replaces cmedia cm6533 24bit 96KHz USB audio codec chip

图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证

VR全景添加对比功能,让差异化效果展示更直观!

4.3寸触控屏12路控制端口可编程网络中控支持5台中控主机相互备份

This morning, investors began to travel collectively
![[solved] how does Tiktok cancel paying attention to the cancelled account](/img/1f/7b0bd2c0f69f7f3d1c25c426cc5771.png)
[solved] how does Tiktok cancel paying attention to the cancelled account
随机推荐
How does an in memory database take advantage of memory?
假期安全不放假,VR交通让孩子安全出行|广州华锐视点
漫画 | Oracle 被新时代抛弃了吗?
码蹄集 - MT3435 · 赋值 - 二分图问题 - 图文讲解
成长一夏 挑战赛来袭 专属社区福利来袭~免费获得CSDN定制T恤衫
条件编译
History, selection strategy and in-depth evaluation of note taking software
6-1漏洞利用-FTP漏洞利用
Code shoe set - mt3435 · assignment - bipartite graph problem - Graphic explanation
Why must a digital transformation strategy include continuous testing?
Cartoon | has Oracle been abandoned by the new era?
启动PHP报错ERROR: [pool www] cannot get uid for user ‘@[email protected]’
neo4j load csv 配置和使用
2022年高考都结束了,还有人真觉得程序员下班后不需要学习吗?
Alibaba Tianchi SQL training camp learning notes 5
无线充U型超声波电动牙刷方案开发
Application of VoIP push in overseas audio and video services
Unity 如何拖拉多个组件中的一个
测试人进阶技能:单元测试报告应用指南
Convert seconds to * * hours * * minutes