当前位置:网站首页>[基础服务] [数据库] MySQL 主从复制部署与配置
[基础服务] [数据库] MySQL 主从复制部署与配置
2022-07-16 13:43:00 【0xYGC】
简介
笔者所用MySQL为8.0.x
前置环境:MySQL已经安装成功
[玩转Linux] [Docker] MySQL安装和配置
方法 / 步骤
一: 主数据库进行配置
1.1: 创建从库账号
- 修改/etc/my.cnf文件, 完成之后重启数据库
[mysqld]
log-bin=mysql-bin #[必须]启用二进制日志
server-id=100 #[必须]服务器唯一ID
重启完成执行以下SQL
-- 创建用户
create user 'slave'@'%' identified by 'useradmin';
-- 用户授权全部权限
grant all privileges on *.* to 'slave'@'%' with grant option;
-- 刷新权限
flush privileges;
show master status;
-- 查看用户权限
show grants for 'slave'@'%';
-- 回收用户所有权限即可
revoke all privileges,grant option from 'slave'@'%';
1.2: 创建从库账号
- 从数据库修改配置后执行SQL
change master to
master_host='192.168.1.220',master_user='slave',
master_port=3307,master_password='useradmin',
master_log_file='mysql-bin.000001',master_log_pos=2297;
-- 开启从库监听
start slave;
-- 开启从库监听
stop slave
-- 查看从数据库状态 注意 Slave_IO_Running 和 Slave_SQL_Running 两个字段都为Yes才为正常
show slave status;

如果不是双yes,有网络 /pos /Ip/账号等等原因, 可以排查之后 用 stop slave 命令关闭然后 执行主库配置然后再开启
然后在主库进行CRUD后从库可以正常同步
stop slave;
-- 表示跳过一步错误,后面的数字可变
set global sql_slave_skip_counter =1;
start slave;
参考资料 & 致谢
边栏推荐
- 【第33天】或运算 | 的使用 | 连续低位0变1
- 进程【详细总结】
- 已解决SQL_ERROR_INFO: “You have an error in your SQL syntax; check the manual that corresponds to your
- C # basic practice of network application programming and asynchronous programming
- 墨者学院刷题笔记——SQL手工注入漏洞测试(MongoDB数据库)
- 20220715 国内Conda不fq安装Pytorch最新版本的方法
- NoSQLAttack工具下载与使用
- (pytorch进阶之路三)conv2d
- 100% accuracy, Alibaba business travel billing system architecture design practice
- MFC problem solving process appmanage
猜你喜欢

【產品人衛朋】2022年產品人必備的13個設計類網站(1.0版)

基于亚马逊云科技无服务器服务快速搭建电商平台——部署篇

C#网络应用编程,实验4:线程管理练习

Z-Wave CTT使用方法以及测试演示

Lime of Py: a detailed introduction to the introduction, installation and use of the lime Library

C#网络应用编程,实验2:IP地址转换和域名解析练习

代码注释的艺术,优秀代码真的不需要注释吗?

Xray安装使用
![(manual) [sqli labs46, 47] order by injection, error echo, post injection, number / character type](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
(manual) [sqli labs46, 47] order by injection, error echo, post injection, number / character type

Use plt When the savefig() method saves the drawing, the picture is all white or all black
随机推荐
IDEA安装、配置、测试
2022 hoisting machinery command examination simulation 100 questions simulation examination platform operation
PNAS | 南农张瑞福组揭示了微生物肥料功能菌根际趋化的信号识别新机制
关于STM32驱动LCD显示屏,程序下载后白屏、乱码需要上电复位才能恢复正常问题的解决办法
Pytorch构建网络细节总结
【產品人衛朋】2022年產品人必備的13個設計類網站(1.0版)
栈的基本操作
(manual) [sqli labs46, 47] order by injection, error echo, post injection, number / character type
【开发教程7】疯壳·开源蓝牙智能健康手表-充电
Xray安装使用
ctf-pikachu-sql
nn.BCEWithLogisticLoss() & nn.BCELoss()的区别 ,nn.CrossEntropyLoss() & nn.NLLLoss()的区别
This article takes you to graph transformers
C#求完全数,输出水仙花以及类的使用
(Note)七彩虹30系列显卡——《一键超频》按键
用NavicatPremium导出数据
[autosar-dem] - 2.4-app SWC how to read mil lamp status and configure mil lamp
准确率100%,阿里商旅账单系统架构设计实践
T-无限的路
Resolved SQL_ ERROR_ INFO: “You have an error in your SQL syntax; check the manual that corresponds to your