客户端不支持服务器请求的身份验证协议考虑升级mysql客户端

时间:2016-02-09 14:02:23

标签: python mysql django

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

  

客户端不支持服务器请求的身份验证协议,考虑升级mysql客户端

然后我这样做: 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.)

2 个答案:

答案 0 :(得分:2)

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

import pymysql

pymysql.install_as_MySQLdb()

答案 1 :(得分:0)

我有一个类似的问题, 我通过将import MySQLdb替换为

来解决此问题
import pymysql
pymysql.install_as_MySQLdb()

settings.py 中。

我正在使用MySQLdb版本1.2.5,PyMySQ版本0.9.2,Python 2.7和Django 1.11.2。