为什么即使在将 mysql 添加到设置后,运行 django 项目也会出现此错误?

Why do I get this error while running django project even after adding mysql to settings?

当我尝试 运行 django 项目时,出现此错误:

django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory")

这似乎是数据库错误。您的数据库设置为使用 caching_sha2_password 作为身份验证插件。您需要从 mysql 配置中更改它。

在您的 mysql 配置文件中,您可能需要更改 default_authentication_plugin 参数:

[mysqld]

default_authentication_plugin=mysql_native_password

您需要重新启动 mysql 服务器才能使此更改生效。

您也可以使用以下 sql 语句由用户更改它:

ALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password';

如果您不依赖于 mysql,您可以将数据库引擎更改为 sqlite 和 运行 项目。如果没有编码错误,应该运行顺利。解决 mysql 问题后,您可以切换回 mysql 后端。