数据库版本:
主服务器:
mysql>CREATE USER 'replicator'@'%' IDENTIFIED WITH 'mysql_native_password' BY 'MyNewPass@123';
mysql>GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%';mysql>show master status\G;
[mysqld]log-bin=mysql-bin #开启二进制日志server-id=1 #设置server-id
从服务器:
[mysqld]
[mysqld]
server-id=2 #设置server-id,必须唯一relay-log=slave-relay-binrelay-log-index=slave-relay-bin.indexread_only=1mysql>reset salve;
mysql>
CHANGE MASTER TO
MASTER_HOST='192..168.0.1', MASTER_USER='replicator', MASTER_PASSWORD='MyNewPass@123', MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=1128;mysql>start slave;
mysql>show slave status\G;