Mikey Mike
Mikey Mike

Reputation: 79

(Python) MySQL database Authentication trouble

I'm trying to run the code below to add the components of the symbols variable into a database called securities_master. I posted this question previously and fixed a substantial amount of the errors, however, I am still receiving the following error:

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

I have tried connecting through both a user that has no password, and through the root user along with the public key for the password, both to no avail. The following is the code I am executing:

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)

Upvotes: 0

Views: 948

Answers (1)

user_D_A__
user_D_A__

Reputation: 460

It seems like the client Endpoint Authentication protocol is not inline with the server. could you please try the below-mentioned steps ? https://dev.mysql.com/doc/refman/5.5/en/old-client.html

Please see the related issue client does not support authentication protocol requested by server consider upgrading mysql client

Upvotes: 1

Related Questions