(python)mysql数据库身份验证问题

eiee3dmh  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(334)

我尝试运行下面的代码,将symbols变量的组件添加到名为securities\u 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

我尝试了通过没有密码的用户和根用户以及密码的公钥进行连接,但都没有效果。以下是我正在执行的代码:

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)
u5i3ibmn

u5i3ibmn1#

客户端端点身份验证协议似乎没有与服务器内联。你能试一下下面提到的步骤吗?https://dev.mysql.com/doc/refman/5.5/en/old-client.html
请参阅相关问题客户端不支持服务器请求的身份验证协议请考虑升级mysql客户端

相关问题