在主库上执行授权
grant replication slave on . to "dba"@"192.168.3.%" identified by "123456";
删除用户
drop user dba@"192.168.3.%";
查看用户
select user,host from mysql.user;
在mysql 5.7中创建用户
create user "dba"@"192.168.3.%" identified by "123456";
对从库用户进行授权
grant replication slave on . to dba@"192.168.3.%";
对数据库进行备份
mysqldump --single-transaction --master-data=2 --triggers --routines --all-databases -uroot -p >all.sql
将备份拷贝到从库上
scp all.sql root@192.168.3.101:/tmp
在从库上恢复数据
mysql -uroot -p
在从库上查看all.sql的内容
more all.sql 并记录change master的内容
在从库上执行命令
change master to master_host="192.168.3.100",
master_user="dba",
master_password="123456",
master_log_file="mysql-bin.000004",
master_log_pos=1687;
start slave;
show slave status \G