1,主库配置
[root@AAA test]# more /etc/my.cnf 
[mysqld]
log-bin=mysql-bin
server-id=1
 
2,主库创建用户
GRANT REPLICATION SLAVE ON *.* TO 'MYTEST'@'%' identified by 'password';
 
3,从库配置
[root@BBB mysql]# more /etc/my.cnf 
[mysqld]
log-bin=mysql-bin
server-id=2
master-host=10.150.60.20
master-user=MYTEST
master-pass=password
master-port=3306
master-connect-retry=60
replicate-do-db=test
 
4,从库启动slave
mysql> start slave;
 
5,查看状态
主:show master status\G
从:show slave status\G
 
6,测试通过!