python - 客户端不支持服务器请求的认证协议(protocol)考虑升级mysql客户端

标签 python mysql django

我想运行 python manage.py syncdb 以使用 Django 构建数据库。但是,我收到以下错误:

client does not support authentication protocol requested by server consider upgrading mysql client

然后我这样做: enter image description here

FUNCTION mysql.old_password 似乎不存在。

一段Django setting.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'blog_list',
        'USER': 'blog_listuser',
        'PASSWORD': '4cZbmXZyyHpAA0oT',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

我使用 Windows 7 和 MySQL 5.7.10。

这是数据库日志错误的一部分:

2016-02-09T07:55:09.032900Z 0 [Note] InnoDB: Waiting for purge to start
2016-02-09T07:55:09.157700Z 0 [Note] InnoDB: Waiting for purge to start
2016-02-09T07:55:09.282500Z 0 [Note] InnoDB: 5.7.10 started; log sequence number 2536368
2016-02-09T07:55:09.282500Z 0 [Note] InnoDB: not started
2016-02-09T07:55:09.547701Z 0 [Note] InnoDB: Loading buffer pool(s) from D:\mysql-5.7.10-win32\data\ib_buffer_pool
2016-02-09T07:55:15.616111Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 6381ms. The settings might not be optimal. (flushed=36 and evicted=0, during the time.)
2016-02-09T07:55:17.659715Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-02-09T07:55:17.690915Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160209 15:55:17
2016-02-09T07:55:18.985717Z 0 [Warning] System table 'plugin' is expected to be transactional.
2016-02-09T07:55:19.188518Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-02-09T07:55:19.219718Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2016-02-09T07:55:19.266518Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-02-09T07:55:19.266518Z 0 [Note] IPv6 is available.
2016-02-09T07:55:19.297718Z 0 [Note]   - '::' resolves to '::';
2016-02-09T07:55:19.360118Z 0 [Note] Server socket created on IP: '::'.
2016-02-09T07:55:19.547318Z 0 [Warning] Failed to open optimizer cost constant tables

2016-02-09T07:55:21.965322Z 0 [Warning] The plugin '*C6E2795BB700C59FE4A4A8E2559543B1AD0263D4' used to authenticate user 'blog_listuser'@'localhost' is not loaded. Nobody can currently login using this account.
2016-02-09T07:55:22.027723Z 0 [Warning] System table 'time_zone_leap_second' is expected to be transactional.
2016-02-09T07:55:22.027723Z 0 [Warning] System table 'time_zone_name' is expected to be transactional.
2016-02-09T07:55:22.027723Z 0 [Warning] System table 'time_zone' is expected to be transactional.
2016-02-09T07:55:22.027723Z 0 [Warning] System table 'time_zone_transition_type' is expected to be transactional.
2016-02-09T07:55:22.027723Z 0 [Warning] System table 'time_zone_transition' is expected to be transactional.
2016-02-09T07:55:22.090123Z 0 [Warning] System table 'servers' is expected to be transactional.
2016-02-09T07:55:36.317347Z 0 [ERROR] Incorrect definition of table mysql.db: expected column 'User' at position 2 to have type char(32), found type char(16).
2016-02-09T07:55:36.332948Z 0 [ERROR] mysql.user has no `Event_priv` column at position 28
2016-02-09T07:55:36.364148Z 0 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
2016-02-09T07:55:36.379748Z 0 [Note] MySQL: ready for connections.
Version: '5.7.10'  socket: ''  port: 3306  MySQL Community Server (GPL)
2016-02-09T09:13:27.113995Z 3 [Warning] The plugin 'mysql_old_password' used to authenticate user 'blog_listuser'@'localhost' is not loaded. Nobody can currently login using this account.
2016-02-09T09:13:27.361009Z 3 [Warning] System table 'servers' is expected to be transactional.
2016-02-09T12:30:51.052347Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 11551607ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)

最佳答案

Django 不会自动生成您的数据库。您必须先创建它,然后再同步或迁移。此外,您需要在 python 包列表中安装 MySQLDB 包。但是,如果您使用的是 Python3,那么我建议您使用 PyMySQL,然后将这些添加到您的 settings.py

import pymysql

pymysql.install_as_MySQLdb()

关于python - 客户端不支持服务器请求的认证协议(protocol)考虑升级mysql客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35294014/

相关文章:

列表的 Pythonic 操作

Django,按字符串过滤比 SQL 关系更快吗?

python - 向现有模型添加字段在 Django 中不起作用

php - MySQL查询: How to join multiple table with statment

mysql | mysql |具体要求

python - 在 Django 中调用添加集中的字段

python - django 日期范围从今天到 10 天前

python - Visual Studio 2019、Python 和 Neuron 模拟器

Python- Selenium 获取错误: Message: Element <g id ="search"> is not reachable by keyboard

MySQL 日期格式将小时-分钟转换为间隔并忽略年-月-日