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

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

问题描述:

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

I want to run python manage.py syncdb to build a database with Django. However, I get the following error:

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

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

然后我这样做:

看来FUNCTION mysql.old_password 不存在.

Django setting.py 的一段:

A section of 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.

I use Windows 7 and MySQL 5.7.10.

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

Here is a part of database log error:

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

Django doesn't automatically generate your database. You must create it first before syncing or migrating. Also, you need to install MySQLDB package on your python package list. But if you're using Python3 then I suggest you use PyMySQL then add these on your settings.py

import pymysql

pymysql.install_as_MySQLdb()