windows 下 MySql5.6主从复制
说明:
1、MySql 版本5.6
2、本例中使用的主从服务器ip分别为:192.168.120.211;192.168.120.209
一、配置master服务器
1、配置
在my.ini中[mysqld]配置如下:
log-bin=mysql-bin
log-bin-index=mysql-bin.index
server-id = 1 --服务Id,和slave 的server-id不一样
sync_binlog=1
binlog_format=mixed
binlog-do-db = testdb --做主从同步的数据库名
binlog-ignore-db = mysql
binlog-ignore-db = performance_schema
binlog-ignore-db = information_schema
网上有种说法max_allowed_packet需要配置一个较大的值。原因未知。
配置完成后重启MySql服务。
2、授权:授权slave同步数据的账号密码。
GRANT REPLICATION SLAVE ON *.*TO 'ROOT'@'192.168.120.209' IDENTIFIED BY 'ROOT';
说明:
- ROOT:Slave使用的账号
- IDENTIFIED BY 'ROOT' :Slave使用的密码
- 192.168.120.209:Slave 数据库IP
master端,通过show master status\G 显示信息。如图:

注意上图中的File,和Position。Slave 中会用到这些信息
一、配置slave服务器
1、修改配置文件
在slave数据库服务器的配置文件中的[mysqld]做如下配置:
server-id=2 --服务Id,和master 的server-id不一样
log-bin = mysql-bin
relay-log-index = slave-relay-bin.index
relay-log = slave-relay-bin
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
2、关联上Master信息
使用如下命令:
change master to master_host='192.168.120.211',master_user='ROOT',master_port=3306,master_password='ROOT',master_log_file='mysql-bin.000001',master_log_pos='332'。
命令说明:
- master_host:master 数据库服务器ip
- master_user: master 数据库通过GRANT授权的账号
- master_port:master 数据库使用的端口号
- master_password:master 数据库通过GRANT授权的密码
- master_log_file:master数据库中通过show master status\G显示的File名称
- master_log_pos:master数据库中通过show master status\G显示的Position数据
重启Slave 的MySql服务
在命令行中输入start slave.
在命令行中输入show slave status\G,显示如下:

注意:只有Slave_IO_Running与Slave_SQL_Running都为Yes才配置成功。
至此,配置全部完成。这样,Master服务器上testDb里的数据就能同步到slave的testDb数据库中.
清同步信息:reset slave all;
windows 下 MySql5.6主从复制的更多相关文章
- windows下MySQL5.6以上版本,如何通过修改配置文件来修改数据库的最大连接数啊?
并没有my.ini文件,只有一个my-default.ini文件,并且里面并没有max_connections windows下MySQL5.6以上版本,如何通过修改配置文件来修改数据库的最大连接数啊 ...
- windows下mysql5.7安装及配置
装完msi后,复制my-default.ini文件,黏贴为my.ini文件,内容修改如下: # For advice on how to change settings please see# htt ...
- windows下Mysql5.7表名不区分大小写问题
前言 Windwos文件系统本身是不区分大小写的,但是Linux文件系统是支持大小写的.于是安装在Linux下的Mysql导出到windows下可能因为大小写问题导致错误,因此要开启window下My ...
- 转载-windows下MySql5.6.17没有setup.exe时的安装方法
转载出处为:http://blog.csdn.net/zgrjkflmkyc/article/details/25321537 (最终,我也没有安装下述的方法安装成功,虽然有服务,但是服务启动不正常, ...
- Windows下MySQL5.6.21安装步骤
01.把 mysql-advanced-5.6.17-winx64.zip 解压到自定义 D:\mysql-5.6.17-W64 或 D:\mysql-advanced-5.6.17-winx64 目 ...
- windows下mysql-5.7.18安装
在官网下载了mysql压缩包,按照官网:https://dev.mysql.com/doc/refman/5.7/en/windows-installation.html的教程安装,但是出错,后面根据 ...
- (二)Windows下Redis的主从复制
Redis拥有非常强大的主从复制功能,而且还支持一个master可以拥有多个slave,而一个slave又可以拥有多个slave,从而形成强大的多级服务器集群架构.目前在同一台window下安装三个r ...
- Windows下mysql5.5主从同步
前置条件: A主机(作为主服务器) 环境:Win7,mysql5.5 IP:172.17.42.82 B主机(作为从服务器) 环境:Win7,mysql5.5 IP:172.17.42.156 主服务 ...
- Windows下Mysql5.7忘记root密码的解决方法
找到mysql5.7安装的目录,我这里是:C:\Program Files\MySQL\MySQL Server 5.7 先停止mysql服务 在服务里找到MySQL57服务,停掉它. 修改my.in ...
随机推荐
- Debian静态IP地址和DNS
Debian静态IP地址和DNS 一.配置文件及路径 /etc/network/interfaces 二.IP地址1. DHCP的IP配置如下 # The primary network interf ...
- springboot 中文文档
springboot 中文文档https://qbgbook.gitbooks.io/spring-boot-reference-guide-zh/content/
- windows下php的各个版本下载地址
windows下php的各个版本 https://windows.php.net/downloads/releases/archives/
- IOS 设备备份文件详解 (二)
这篇主要讲解如何解析Manifest.mbdb文件. 使用二进制工具打开这个文件,文件的头6个字节是固定的,相当于是文件的一种标识 后面的内容是一个一个的项,可以使用一个循环来读取文件,一个一个解析. ...
- [svc]ansible自动化模块
ansible命令执行模块 - command模块 [执行远程命令] $ ansible n1 -m command -a 'uname -n' - raw模块 [类似于command模块.支持管道传 ...
- [svc][cpu][jk]cpu的核心查看及什么是cpu的负载
监控的时候我们会监控cpu的负载,那么什么是负载? 编程时候有多核多线程的概念,那么cpu内部如何运作的? 搞清多少bit cpu? 有几个物理cpu?每个cpu是几核的? 之前购买内存条时候,需要关 ...
- Android 录音获取分贝值的办法
参考:http://blog.csdn.net/greatpresident/article/details/38402147 public class MediaRecorderDemo { pri ...
- OpenCV中图像算术操作与逻辑操作
OpenCV中图像算术操作与逻辑操作 在图像处理中有两类最重要的基础操作各自是图像点操作与块操作.简单点说图像点操作就是图像每一个像素点的相关逻辑与几何运算.块操作最常见就是基于卷积算子的各种操作.实 ...
- 每日英语:American Cities May Have Hit 'Peak Office'
Despite some hype and a few regional exceptions, the construction of office towers and suburban offi ...
- git(8):常用命令
Git常用操作命令收集: 1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquery.git 查看远程仓库:$ git remote -v ...