首页 > 解决方案 > Why do I get this error while running django project even after adding mysql to settings?

问题描述

When I try to run the django project, I get this error:

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")

标签: djangopython-3.xmysql-python

解决方案


这似乎是一个数据库错误。您的数据库设置为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 后端。


推荐阅读