1、主库
设置 my.cnf
server_id = 2 必须唯一
binlog-do-db = abo-assist 备份的数据库
log-bin=mysql-bin 开启 binlog
创建同步账号并授权
CREATE USER 'repl'@'%' IDENTIFIED WITH 'mysql_native_password' BY '123456';
GRANT REPLICATION SLAVE ON . TO 'repl'@'%';
flush privileges;
2、备份主库数据库,一定要带上 master-data
mysqldump -uroot -p --databases coin --master-data=1>/var/lib/mysql/XXX.sql
3、从库导入数据并记下 master_log_file 与 master_log_pos 的位置,参考下图
从库导入:
mysql -uroot -p
uset ..
source
2、从库
server_id = 10 必须唯一
3、开启主从同步(从库上操作)
mysql> stop slave;
mysql>change master to master_host='192.168.190.131',master_user='replication',master_password='123456',master_port=3336,master_log_file='mysql-bin.000001',master_log_pos=641134;
mysql> start slave;
备注
清除从库日志
mysql>show slave status\G (查看从库备份状态)
mysql>reset master
mysql 访问外部地址
myql -h192.168. -uroot -p -P3306
标签:log,Centos,备份,Mysql,master,mysql,uroot,从库,主从 From: https://www.cnblogs.com/abowu/p/18199020