主库:
创建复制用户
create user 'slave'@'IP' identified by 'password';
grant replication slave on *.* to 'slave'@'IP';
flush privileges;
select user,host from mysql.user;
show grants for 'slave'@'IP';
show master status;
从库:
修改配置文件my.cnf(指定同步某张表)- 可使用rewrite同步至其他库
server-id = 102
replicate-do-db = exam
replicate-wild-do-table=exam.exam_result
CHANGE MASTER TO MASTER_HOST='mysql-IP',MASTER_PORT=3306,MASTER_USER='slave',MASTER_PASSWORD='password',MASTER_LOG_FILE='mysql-bin.000041',master_log_pos=88483159;
start slave;
show processlist;
show slave status\G;
取消主从
stop slave;
reset slave all;