mysql8.0.20 部署主从复制

愿天下再无BUG 2020-05-31

master庫:192.168.1.25
mysql -e "reset master;"
mysql -e "create user ‘192.168.1.%‘ ; grant replication slave on *.* to ‘192.168.1.%‘;"
ALTER USER ‘192.168.1.%‘  IDENTIFIED WITH mysql_native_password BY ‘OrcSdk21TbUserUi‘;FLUSH PRIVILEGES;

mysqldump -uroot -p‘rRt&8v7Cx‘ -B -A -F --set-gtid-purged=OFF  --master-data=2 --single-transaction  --events|gzip >/opt/test_$(date +%F).sql.gz

slave库1:192.168.1.182

mysql < /opt/test_2020-05-28.sql
mysql  -e "CHANGE MASTER TO MASTER_HOST=‘mysql-redis25‘,MASTER_PORT=3306,MASTER_USER=‘repuser‘,MASTER_PASSWORD=‘OrcSdk21TbUserUi‘,MASTER_AUTO_POSITION = 1;start slave;show slave status\G" |grep -i "yes"

slave库2:192.168.1.39

mysql < /opt/test_2020-05-28.sql
mysql  -e "CHANGE MASTER TO MASTER_HOST=‘mysql-redis25‘,MASTER_PORT=3306,MASTER_USER=‘repuser‘,MASTER_PASSWORD=‘OrcSdk21TbUserUi‘,MASTER_AUTO_POSITION = 1;start slave;show slave status\G" |grep -i "yes"

报错2061
在show slave status\G 报错2061的原因:
mysql8.0 开始默认的加密方式和解密方式和传统的mysql5.7 mysql5.6是有区别的,具体自行百度查看。
解决办法就是在master库机器192.168.1.25 机器alter重新创建create 账户

ALTER USER ‘192.168.1.%‘  IDENTIFIED WITH mysql_native_password BY ‘OrcSdk21TbUserUi‘;FLUSH PRIVILEGES;

相关推荐