MySQL8.0主从配置,从库连接报错:Authentication plugin 'caching_sha2_password' reported error

在MySQL8.0中,change master to时,不指定get_master_public_key参数,报错如下:
error connecting to master 'slave@192.168.56.104:3306' - retry-time: 60 retries: 6 message:
Authentication plugin 'caching_sha2_password' reported error: 
Authentication requires secure connection.

show slave status; 查看从库状态时,Slave_IO_Running=connecting


原因:
在MySQL8.0中,复制账号slave的密码加密用的插件是 caching_sha2_password。


解决方法一:修改master库的密码加密方式
alter user 'slave'@'%' identified with  mysql_native_password  by 'slave';


解决方法二:设置从库的change master 时加get_master_public_key=1参数
之前准备配置前,查询资料,看到过有人特意设置过get_master_public_key这个参数,加上这个参数再次配置:

1.从库执行 stop slave;

2.清除从库配置:reset slave all;

3.重新配置主库信息

change master to master_host='192.168.56.104', master_user='slave', master_password='slave', master_log_file='mysql-bin.000002', master_log_pos=157, get_master_public_key=1;

 

posted @ 2023-05-20 15:19  屠魔的少年  阅读(29)  评论(0)    收藏  举报