MySQL8 2061错误的处理

Last_IO_Errno: 2061
                Last_IO_Error: error connecting to master 'repl@210.14.75.1:3306' - retry-time: 60 retries: 1 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.

错误原因详解

caching_sha2_password 是 MySQL 8.0 及以上版本的默认认证插件,它有一个安全特性:默认要求通过 SSL 加密连接来进行认证。你的从库尝试以普通方式连接主库,触发了这个安全限制,因此报出 “Authentication requires secure connection” 错误。

登录主库 MySQL 执行以下命令,确认 have_sslYES

修改从库的复制连接配置,添加ssl相关参数:

-- 先停止复制
STOP SLAVE;

-- 修改主库连接信息,启用 SSL
CHANGE MASTER TO
  MASTER_HOST='210.14.75.1',
  MASTER_PORT=3306,
  MASTER_USER='repl',
  MASTER_PASSWORD='你的主库repl用户密码',
  MASTER_SSL=1,  -- 启用SSL
  MASTER_AUTO_POSITION=1;

-- 启动复制
START SLAVE;

-- 检查复制状态
SHOW SLAVE STATUS\G;
Categories: 数据库运维