### 配置主數據庫 my.cnf
server-id=1
log-bin=master-bin
log-bin-index=master-bin.indexmysql
### 在主數據庫上建立同步帳號
create user backup;
GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql';sql
### 配置從數據庫 my.cnf
server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin數據庫
### 重啓mysql服務
service mysqld restartui
### 鏈接Master服務
change master to master_host='192.168.91.128',master_port=3306,master_user='backup',master_password='mysql',master_log_file='master-bin.000001',master_log_pos=0;rest
### 啓動slave服務
start slave;server
### 查看Master服務狀態
SHOW MASTER STATUS;同步
### 查看Slave服務狀態
SHOW slave STATUS \G;io
### 檢查server_id是否同樣,須要不同
show variables like 'server_id';ast
====常見錯誤==============================================================
錯誤: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
解決方式: 檢查data目錄中的auto.cnf中的server-uuid=******************** 是否同樣的,要改成不同thread