I'm trying to connect to a remote MySQL server, specifically using Python 2.7/pandas/sqlalchemy.
I installed installed mysql-connector-python, then initiated iPython in my terminal, then tried:
import pandas as pd
from pandas import Series, DataFrame
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqlconnector://scott:tiger@localhost:3306/foo')
test_q = pd.read_sql_query('SELECT COUNT(users.id) FROM users', engine)
Of course, the create_engine() here is not the actual connection, it's just an example.
I'm getting the error:
NotSupportedError: (NotSupportedError) Authentication plugin 'mysql_old_password' is not supported None None
I'm having a difficult time understanding this error and how to fix it. I think there might be something about the fact that I'm just sending the password as a string, whereas it may require some type encryption.
So based on this documentation, I tried:
import hashlib
hash_object = hashlib.sha256(b'tiger')
engine = create_engine('mysql+mysqlconnector://scott:' + hash_object + '@localhost/foo')
Which raised the error:
TypeError: cannot concatenate 'str' and '_hashlib.HASH' objects
So now I think I need to use the engine creation API to create the connection object. The custom dbapi connection could be another possibility, but I'm still at a loss though following the directions for either. Any ideas?