0

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?

measureallthethings
  • 1,102
  • 10
  • 26
  • 2
    See http://stackoverflow.com/questions/13706463/authentication-method-mysql-old-password-not-supported – joris Sep 12 '14 at 19:57
  • I'm not the admin for the DB and I don't think they're going to change anything to 'old_passwords=1'; from the link provided looks like I'm SOL? – measureallthethings Sep 12 '14 at 20:16
  • 1
    Then you need to install an older version of `mysql-connector` that is compatible with the database I think – joris Sep 12 '14 at 20:18
  • Thanks joris; sent these links to the admin and looks like they have a mirror of the DB exactly for things like this. It's working now :-) – measureallthethings Sep 12 '14 at 20:30

0 Answers0