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

问题描述 投票:3回答:1

[运行命令时: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 Community Server-GPL)
  • python 3.7.4
  • Django 2.2.4
  • mysqlclient 1.4.4
python mysql django python-3.x mysql-connector
1个回答
0
投票
尝试

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

© www.soinside.com 2019 - 2024. All rights reserved.