MySQL主从实时备份

1 主A从B电脑ip
A:192.168.1.111
B:192.168.1.112


2 给主A从B电脑创建相同数据库


3 授权(主从都需要)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH  PRIVILEGES;


grant file on *.* to 'root'@'192.168.1.112' identified by 'root' with grant option;
grant all on backup.* to 'root'@'192.168.1.112' identified by 'root' with grant option;
grant all on backup.* to 'root'@'localhost' identified by 'root' with grant option;
grant replication slave on *.* to 'root'@'192.168.1.112' identified by 'root' with grant option;
flush privileges;


4 my.ini配置

[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
server-id=200
log-bin=mysql-bin
relay-log=relay-bin
relay-log-index=relay-bin-index

[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
server-id=210
replicate-do-db=dbname


5 重启两台机器的mysql服务


6 在从数据库执行下命令,注意还原点参数。
mysql> stop slave;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> change master to master_user='root',master_password='root',master_host='192.168.1.111',master_port=3306,master_log_file='mysql-bin.000002',master_log_pos=120;
mysql> start slave;


7 查看状态
show slave status;
show master status;

show processlist;






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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值