我在 Debian 服务器上使用 MySQL 版本 8.0.34。在最新的更新中,我收到消息 mysql_native_password 已弃用,我应该使用 caching_sha2_password 代替。对于我自己的用户来说这没有问题,在这里我可以简单地更改身份验证插件。
ALTER USER user
IDENTIFIED WITH caching_sha2_password
BY 'password';
但是集成用户 mysql.sys、mysql.session 和 debian-sys-maint 又如何呢?我没有创建这些,它们不用于用户登录,因此我没有它们的密码。我如何在这里更改为caching_sha2_password?
ALTER USER user
IDENTIFIED WITH caching_sha2_password;
在 SQL 语句中省略密码只会导致错误。
谢谢
您很可能在日志中发现了此错误消息:
[MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
如果您更改了现有用户的身份验证方法,则该消息应该已经消失(不会报告内置用户使用旧方法)。
当该功能最终被删除时,内置用户的方法 -
mysql.session
、mysql.sys
或mysql.infoschema
- 将由安装程序更改。您不应更改这些用户的密码。如果需要,您可以轻松更新 auth 方法
debian-sys-maint
:/etc/mysql/debian.cnf
(查找password = ...
)ALTER USER 'debian-sys-maint'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'your-password-here';
(稍后也可能由 MySQL 安装程序处理,但由于密码已知,因此手动操作没有风险)。