本文最后更新于 2023-11-28,文章内容可能已经过时。

主数据库

CREATE USER 'slave'@'%' IDENTIFIED BY 'Password.123';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'%';
show master status;---position 和LogFileName 很重要
​
ALTER USER 'slave'@'%' IDENTIFIED WITH mysql_native_password BY 'Password.123';

从数据库

change master to master_host='220.167.187.41', master_user='slave', master_password='Password.123', master_port=316, master_log_file='mysql-bin.000001', master_log_pos= 446, master_connect_retry=30;
​
show slave status;
start slave;
stop slave;
​
​

master_log_pos---Position

master_log_file='mysql-bin.000001-=-file