标签:pos ati ast 从库 授权 grant mysql serve 主从
master:server-id:3
slave:server-id:4
master开启binlog
#master授权:
grant replication slave on *.* to ‘rep‘@‘192.168.1.%‘ identified by ‘xxxxx‘;
1、主库备份时(定时任务):
mysqldump -uroot -p -A --events -B -x --master-data=1|gzip >/opt/$(date +%F).sql.gz
2、从库上(白天搞即可):
gzip -d 2019-11-27.sql.gz
mysql -uroot -p <2019-11-27.sql
3、查看2019-11-27.sql
第一条是这个:CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000001‘, MASTER_LOG_POS=657262842;
4、登录slave的数据库
CHANGE MASTER TO
MASTER_HOST=‘192.168.1.55‘,
MASTER_PORT=3306,
MASTER_USER=‘rep‘,
MASTER_PASSWORD=‘xxxxx‘,
MASTER_LOG_FILE=‘mysql-bin.000001‘,
MASTER_LOG_POS=657262842;
start slave;
show slave status\G
标签:pos ati ast 从库 授权 grant mysql serve 主从
原文地址:https://www.cnblogs.com/wangkaiok/p/11942834.html