mysql 主從配置筆記

來源:互聯網
上載者:User

標籤:bin   char   drop   default   log-bin   csharp   --   serve   color   

1.master配置

server-id=1log-bin=mysql-binbinlog-do-db=testdatabinlog-ignore-db=mysql

 2.master增加使用者

 grant replication slave on *.* to ‘test‘ @‘192.168.176.%‘ identified by ‘123456‘;

 3.從資料庫檢測是否可以遠端連線主要資料庫

筆記:防火牆3306連接埠開通 iptables -I INPUT -s 0/0 -p tcp --dport 3306 -j ACCEPT  查看iptables -L -n|grep 3306

4.從資料庫配置

server-id=2expire_logs_days=10max_binlog_size=100Mrelay-log=slave-relay-binrelay-log-index=salve-relay-bin.index

5.登入從資料庫

1.reset slave;

2.change master to master_host=‘192.168.176.3‘,master_port=3306,master_user=‘test‘,master_password=‘123456‘,master_log_file=‘mysql-bin.000003‘,master_log_pos=120;

,master_log_file與master_log_pos 在主要資料庫 show master status;中查看

3.start slave;

筆記,不同資料庫複寫庫表 :mysqldump testdata -uroot -proot --add-drop-table | mysql -h 192.168.176.4 testdata -u root -proot
前提,1.目標資料庫建好庫 CREATE DATABASE  `wordpress` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

           2.授權遠端連線GRANT ALL PRIVILEGES ON *.* TO [email protected]"%" IDENTIFIED BY "root";

 

mysql重啟  service mysqld restart 設定檔 :/etc/my.cnf

mysql 主從配置筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.