MySQL错误 Message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection. Error_code: MY-002061
使用 MySQL 8.0.34 创建主从备份,从库日志报错:
Message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection. Error_code: MY-002061
原因:
在 MySQL 8.0+ 中,caching_sha2_password 是默认的身份验证插件,而不是之前的 mysql_native_password 。
要使用通过caching_sha2_password插件进行身份验证的帐户连接到服务器,必须使用支持使用RSA密钥对进行密码交换的安全连接或未加密连接。
即使将主库创建同步账户由:
create user '[backup_account]'@'[从库IP]' identified by '[backup_password]';
改为:
create user '[backup_account]'@'[从库IP]' identified with caching_sha2_password by '[backup_password]';
问题依旧。
可以通过将当前默认的身份验证方式由 caching_sha2_password 改为之前的 mysql_native_password 来解决问题。
方法1:在 MySQL 配置文件中修改身份验证方式。
centos 该文件位于 /etc/my.conf,debian 系统该文件位于 /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
default_authentication_plugin = mysql_native_password
修改完成后重启即可。
方法2:修改同步账户的身份验证方式。
alter user '[backup_account]'@'[从库IP]' identified with mysql_native_password by '[backup_password]';
通过该命令查看身份验证方式:
show variables like 'default_authentication_plugin';
我的笔记