0

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)

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

I went to try out your suggestion of using the OLD_PASSWORD() function to reset my password to one compatible, but was met with a syntax error telling me to check for the syntax in the manual for my version. Turns out that OLD_PASSWORD() has been removed for MySQL 8.0 …. dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html
I ended up getting it to work by using the command: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password' Your answer helped lead me to the right way so thank you.
hey @Mikey Mike could you explain where you typed in the ALTER USER... query to fix your problem, was it at the mysql prompt, I tried typing it there but all that happened was the arrow prompt ->, I am still having the OperationalError

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.