mysql 主从复制配置

2017-06-22  本文已影响31人  Rohn

主库master

server-id=1 
log-bin=log
binlog-do-db=dbname #同步dbname数据库,要同步多个数据库,就多加几个replicate-db-db=数据库名
binlog-ignore-db=mysql #要忽略的数据库

从库slave

CHANGE MASTER TO
    Master_Host='ip',  #主机IP
    Master_Port=3306,
    Master_User='account',
    Master_Password='dbname',
    Master_Connect_Retry=60;

验证主从

CREATE TABLE IF NOT EXISTS `test` (
      `id` INT UNSIGNED AUTO_INCREMENT,
      PRIMARY KEY (`id` )
  )ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO \test` VALUES (1);`

SELECT * FROM `test`;

想了解原理请看

http://www.hoohack.me/2017/07/11/learning-mysql-replication-detail

上一篇下一篇

猜你喜欢

热点阅读