标题: mysql_native_password is deprecated and will be removed in a future release [打印本页] 作者: 刘泽宇 时间: 2023-9-17 12:53 标题: mysql_native_password is deprecated and will be removed in a future release 如果你的MySQL的用户还在使用mysql_native_password(密码插件)的认证方式,那么在MySQL更新到8.0.34后,每次数据库用户以mysql_native_password方式访问MySQL,日志就会输出mysql_native_password已经废弃,即将在未来版本移除,以caching_sha2_password替代。
日志原文:
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自带的账户,通过SQL来更新认证模式和密码:
ALTER USER '用户名'@'域' IDENTIFIED WITH caching_sha2_password BY '密码';
必须附带密码(可以用旧密码),因为加密方式不一样。你不改密码直接通过UPDATE改用户认证模式到caching_sha2_password,MySQL会输出日志提示该用户无效,忽略。
Found invalid password for user: '用户名@域'; Ignoring user
而MySQL自身的账户,可以通过以下SQL更新到caching_sha2_password模式:
UPDATE mysql.user SET plugin='caching_sha2_password' WHERE user='mysql.session' OR user='mysql.sys' OR user='mysql.infoschema';
UPDATE mysql.user SET authentication_string='$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED' WHERE user='mysql.session' OR user='mysql.sys' OR user='mysql.infoschema';