主庫配置 server_id=1read-only=0replicate-do-db=mydatalog-bin=mysql-bin 主庫許可權設置 GRANT replication slave ON *.* TO'backup'@'%' identified BY 'password'; flus ...
主庫配置
server_id=1
read-only=0
replicate-do-db=mydata
log-bin=mysql-bin
主庫許可權設置
GRANT replication slave ON *.* TO'backup'@'%' identified BY 'password';
flush PRIVILEGES;
GRANT EXECUTE, SELECT, SHOW VIEW, ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, INDEX, INSERT, REFERENCES, TRIGGER, UPDATE, LOCK TABLES ON `mydata`.* TO 'backup'@'%' WITH GRANT OPTION
FLUSH PRIVILEGES;
show master status
從庫配置:
server_id=2
read-only=1
replicate-do-db=mydata
log-bin=mysql-bin
change master to MASTER_HOST='172.20.42.224', MASTER_USER='backup',MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000085',MASTER_LOG_POS=839, master_connect_retry=60,MASTER_PORT=3307
註意點:mysql-bin.000085 和 839 這2個參數來自主庫show master status的查詢。
stop SLAVE
START slave
SHOW SLAVE status
這三個狀態 slave_IO_state、slave_IO_running、slave_SQL_running 是yes,配置成功。