項目需求:
1:主資料庫ip:192.168.1.31從資料庫ip:192.168.1.32
2:建立主從關系,實作資料主從同步
實作步驟:
[root@zhu~]#vim/etc/my.cnf
[mysqld]
server_id=31
log_bin
[root@zhu~]#servicemysqlrestart
2:給從資料庫使用者授權
mysql>grantreplicationslaveon*.*toslave@"192.168.1.32"identifiedby"123";
3:配置從資料庫的主配置檔案,重新開機服務
[root@cong~]#vim/etc/my.cnf
server_id=32
[root@cong~]#servicemysqlrestart
4:從資料庫指定主資料庫參數
mysql>changemasterto
->master_host="192.168.1.31",
->master_user="slave",
->master_password="123",
->master_log_file="localhost-bin.000001",
->master_log_pos=472;
5:開啟從資料庫同步功能
最新内容請見作者的github頁:http://qaseven.github.io/