mysql8.0.20 部署主从复制

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8.0.20 部署主从复制相关的知识,希望对你有一定的参考价值。

master庫:192.168.1.25

mysql -e "reset master;"
mysql -e "create user repuser@‘192.168.1.%‘ ; grant replication slave on *.* to repuser@‘192.168.1.%‘;"
ALTER USER repuser@‘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 statusG" |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 statusG" |grep -i "yes"

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

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

以上是关于mysql8.0.20 部署主从复制的主要内容,如果未能解决你的问题,请参考以下文章

mysql8.0.20安装测试innodb cluster

mysql8.0.20安装测试innodb cluster

源码编译安装MySQL8.0.20

源码编译安装MySQL8.0.20

源码安装mysql8.0.20

MySQL8.0.20安装