我的日志中大量出现这个错误,如何对应?

2025-06-25T01:08:35.625937Z 70171 [Warning] [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_native_password 身份验证插件,并建议你转移到新的 caching_sha2_password 插件

解决方法:

找到 MySQL 配置文件

 宝塔 /etc/my.cnf 右上角搜索my.cnf

搜索 default_authentication_plugin 行并修改为:

default_authentication_plugin = mysql_native_password

default_authentication_plugin = mysql_native_password

修改成下面的

default_authentication_plugin = caching_sha2_password

default_authentication_plugin = caching_sha2_password

修改完成后,重启 MySQL 服务使配置生效:

sudo service mysql restart

验证修改成果 重启服务后,可以通过以下命令验证认证插件是否已更改:

注意:在数据库执行下面的代码sql

SHOW VARIABLES LIKE 'default_authentication_plugin';

应该看到输出:

+-------------------------------+-----------------------+
| Variable_name                 | Value                 |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐