ERROR 2061 (HY000): Authentication plugin ‘caching_sha2_password‘ reported error: Authentication req

📅 2026/6/17 9:46:32
ERROR 2061 (HY000): Authentication plugin ‘caching_sha2_password‘ reported error: Authentication req
这个错误ERROR 2061 (HY000): Authentication plugin caching_sha2_password reported error: Authentication requires secure connection.说明MySQL 用户使用的是caching_sha2_password认证方式MySQL 8 默认当前客户端连接没有 SSL/TLS服务端要求通过安全连接传输密码因此认证失败先确认用户认证方式登录 root 后查看SELECT user, host, plugin FROM mysql.user WHERE userreadonly_user;如果看到readonly_user % caching_sha2_password就是这个原因。方案一使用 SSL 连接推荐客户端连接时开启 SSLmysql -h mysql.example.com \ -u readonly_user \ -p \ --ssl-modeREQUIRED或者mysql --ssl-modePREFERRED如果服务器配置了证书mysql \ --ssl-caca.pem \ --ssl-modeVERIFY_CA \ -u readonly_user \ -p方案二改成 mysql_native_password如果是内网环境很多老程序不支持caching_sha2_password可以改回旧认证方式ALTER USER readonly_user% IDENTIFIED WITH mysql_native_password BY 新密码;然后FLUSH PRIVILEGES;验证SELECT user, host, plugin FROM mysql.user WHERE userreadonly_user;应该变成readonly_user % mysql_native_password之后普通连接即可mysql -u readonly_user -p方案三升级客户端很多时候服务器没问题而是客户端太老查看版本mysql --version例如mysql Ver 14.14 Distrib 5.7.xx连接 MySQL 8 时经常出现认证问题。建议使用 MySQL 8 客户端brew install mysql-client然后/opt/homebrew/opt/mysql-client/bin/mysql \ -h xxx \ -u readonly_user \ -p快速判断执行SELECT user, host, plugin FROM mysql.user WHERE userreadonly_user;再告诉我mysql --version以及 MySQL 服务端版本SELECT VERSION();我可以直接判断是客户端太老SSL 没开认证插件不兼容中的哪一种。