在master创建一个用户,用来做数据同步:
create user 'repl'@'%' identified by 'Abc123!@#';
grant replication slave on *.* to 'repl'@'%';
flush privileges;
master配置
log_bin=mysql-bin
server_id=1
slave配置
server_id=2
在master执行
show master status;
File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
---|---|---|---|---|
mysql-bin.000001 | 1418 |
在slave执行
stop slave;
CHANGE MASTER TO MASTER_HOST='192.168.9.107', MASTER_USER='repl', MASTER_PASSWORD='Abc123!@#', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=154;//MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=154; 来自在master 执行的结果
start slave;
show slave status \G;
执行预期结果:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes