主庫192.168.88.1
從庫192.168.88.88
主庫配置文件[my.ini]添加
server-id = 1 1代表主庫
log-bin
binlog-do-db=log 同步的數(shù)據(jù)庫 多個數(shù)據(jù)庫繼續(xù)添加binlog-do-db=
binlog-ignore-db=nolog 不同步的數(shù)據(jù)庫
重啟mysql
從庫配置文件[my.ini]添加
master-host=192.168.88.1
master-user=loguser 用戶
master-password=123456 用戶
master-port=3306
server-id=2 2代表從庫
master-connect-retry=60
replicate-do-db=log 復制的數(shù)據(jù)庫 多個數(shù)據(jù)庫繼續(xù)添加replicate-do-db=
重啟mysql
主庫授權
GRANT REPLICATION SLAVE ON *.* TO loguser@'%' IDENTIFIED BY '123456';
flush privileges;
查看主庫狀態(tài)
mysql>show master status;
mysqld-bin.000003 | 1399 | log | nolog
從庫中設置replication位置
mysql >change master to master_host='192.168.88.1',master_port=3306,master_user='loguser',master_password='12346', master_log_file='mysql-bin.000003',MASTER_LOG_POS=1399;
啟動從庫
mysql >slave start;
|