(Python)MySQL数据库认证麻烦

(Python) MySQL database Authentication trouble

我正在尝试 运行 下面的代码将 symbols 变量的组件添加到名为 securities_master 的数据库中。我之前发布了这个问题并修复了大量错误,但是,我仍然收到以下错误:

Traceback (most recent call last):

 File "C:/Users/Nathan/.PyCharmCE2018.1/config/scratches/scratch.py", line 28, in <module>
insert_btc_symbols(symbols)
 File "C:/Users/Nathan/.PyCharmCE2018.1/config/scratches/scratch.py", line 15, in insert_btc_symbols
con = MySQLdb.connect(host=db_host,user=db_user,db=db_name) #,passwd=db_pass
 File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
 File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')

Process finished with exit code 1

我试过通过没有密码的用户连接,以及通过 root 用户连同密码的 public 键连接,都无济于事。以下是我正在执行的代码:

import datetime
import MySQLdb
from math import ceil

def obtain_btc():
    now = datetime.datetime.utcnow()
    symbols = ['BTC', 'Crypto', 'Bitcoin', 'No Sector', 'USD', now, now]
    return symbols

def insert_btc_symbols(symbols):
    db_host = 'localhost'
    db_user = 'natrob2'
    #db_pass = ''
    db_name = 'securities_master'
    con = MySQLdb.connect(host=db_host,user=db_user,db=db_name) #,passwd=db_pass
    column_str = "ticker, instrument, name, sector, currency, created_date, last_updated_date"
    insert_str = (("%s, ")*7)[:2]
    final_str = ("INSERT INTO symbol (%s) VALUES (%s)" % (column_str,insert_str))
    print (final_str,len(symbols))

    with con:
        cur = con.cursor()
        for i in range(0,int(ceil(len(symbols)/100.0))):
            cur.executemany(final_str,symbols[i*100:(i+1)*100-1])

if __name__ == "__main__":
    symbols = obtain_btc()
    insert_btc_symbols(symbols)

客户端端点身份验证协议似乎与服务器不一致。 你能试试下面提到的步骤吗? https://dev.mysql.com/doc/refman/5.5/en/old-client.html

请查看相关issue client does not support authentication protocol requested by server consider upgrading mysql client