1、在主库设置
GRANT REPLICATION SLAVE ON *.* TO 'username'@'127.0.0.1' IDENTIFIED BY 'password';
2、查看主库状态,拿到bin-log和postion
show master status
3、在从库设置
change master to
master_host='127.0.0.1',
master_user='username',
master_log_file='mysql-bin.000001', #show master status拿到的值
master_log_pos=1029250,#show master status拿到的值
master_port=3306, #主库端口
master_password='password';
4、开启
start slave; #stop slave;
5、查看状态
show slave status;
其他命令
重置主节点命令: reset master; reset slave;
reset master; reset slave;