Django + MySQL-“无法加载身份验证插件'caching_sha2_password'”

时间:2019-08-20 12:52:13

标签: python mysql django python-3.x mysql-connector

运行命令:python manage.py runserver时出现以下错误:

django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.\r\n")

这些是相关设置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'polls',
        'USER': 'root',
        'PASSWORD': '<my-password>',
        'HOST': 'localhost'
    }
}

我已经看到解决该问题的解决方案,例如this thread。他们建议将引擎更改为mysql.connector.django,但是django推荐的引擎为mysqlclient,因此我想使用它。 其他建议是use naive password instead of sha2。出于安全原因,我宁愿不使用此解决方案。

版本:

  • 用于x86_64上Win64的MySQL 8.0.17(MySQL社区服务器-GPL)
  • python 3.7.4
  • Django 2.2.4
  • mysqlclient 1.4.4

1 个答案:

答案 0 :(得分:0)

尝试

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<my-password>';
相关问题