主:
配置my.conf
log-bin=mysql-bin
server-id = 1
binlog-do-db=jinrimingpin_com
binlog-do-db=jinripinpai_com
binlog-do-db=jinritemaihui_com
binlog-do-db=mingpintejia_com
binlog-do-db 是允許同步的數據庫。一行一個。
SHOW MASTER STATUS
mysql-bin.000001 4658 下面設置從庫要用 change master to
然後導數據到從庫。
新建一個可讓從庫訪問的賬號。
grant replication slave on *.* to “congku”@”xxxx” identified by “密碼”;
flush privileges;
從:
配置my.conf
server-id = 2
replicate-do-db=mingpintejia_com
slave_skip_errors = 1062,1032
從庫要同步的數據庫 replicate-do-db
mysql -u congku -p -h xx.xx.xx.xx 檢測是否可以連接主服務器
slave stop;
CHANGE MASTER TO
MASTER_HOST=’xxx’,MASTER_USER=’congku’,MASTER_PASSWORD=’密碼’,MASTER_LOG_FILE=’mysql-bin.000002′,MASTER_LOG_POS=102470;
start slave;
確保:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes