mysql不同用户相同库名_MySql 主从同步 (库名不同)

主库:192.168.1.250

从库:192.168.1.199

主库  my.ini

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

# 以下内容手动添加

[client]

default-character-set=utf8

[mysqld]

port=3306

server-id=1

log-bin=mysql-bin

binlog-do-db=kintech_pd

sync_binlog=1

basedir=C:\ProgramData\MySQL\MySQL Server 5.7

#解压目录下data目录

datadir=C:\ProgramData\MySQL\MySQL Server 5.7\data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[WinMySQLAdmin]

C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe

从库 my.ini

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

# 以下内容手动添加

[client]

default-character-set=utf8

[mysqld]

#从库配置

server_id=2

#如果库名相同,使用这个

#replicate-do-db=kintech_pd

#如果库名不同,使用这个。

replicate-rewrite-db = kintech_pd -> kps_common

#端口

port=3306

character_set_server=utf8

#解压目录

basedir=C:\ProgramData\MySQL\MySQL Server 5.7

#解压目录下data目录

datadir=C:\ProgramData\MySQL\MySQL Server 5.7\data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[WinMySQLAdmin]

C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe

主库:记住 File 和 Position

CREATE USER 'slave'@'MySql2服务器ip' IDENTIFIED BY '密码';

GRANT REPLICATION SLAVE ON *.* TO 'slave'@'MySql2服务器ip';

flush privileges;

show master status;

从库:

CHANGE MASTER TO

master_host = 'MySql1服务器ip',

master_user = 'slave',

master_password = '密码',

master_log_file = 'bin_log.000002',

master_log_pos = 631;

start slave;

show slave status\G

最后显示:

90966125722b1d9031d014a323cf47e5.png

代表成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值