shinytinsmile shinytinsmile - 1 year ago 244
MySQL Question

Using MySQLdb Python module with mysql_old_password

I need to use Python to connect to a database that uses the mysql_old_password authentication plugin. I do not have db admin access so I cannot change this setting, so please do not suggest that.

I just installed the MySQLdb module, downloaded here. Other stackoverflow questions on this matter have led me to believe that it is possible to use the old authentication with this module, but when I set up my connection (db info removed for privacy reasons), I get the following error:

('Unexpected error:', <class '_mysql_exceptions.OperationalError'>)
Traceback (most recent call last):
File "", line 48, in <module>
File "", line 25, in main
prod_con = MySQLdb.connect('xxxx', 'xxxx', 'xxxx', 'xxxx')
File "/Library/Python/2.7/site-packages/MySQLdb/", line 81, in Connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/MySQLdb/", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2059, "Authentication plugin 'mysql_old_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/, 2): image not found")

This seems to indicate that I just need to download the plugin image from somewhere - is this possible? Or is there some field I can set using MySQLdb that will allow me to connect?

Answer Source

mysql_old_password support was removed from the mysql client libraries in 5.7.5, so you're probably using a newer version of the client libraries then that.

You'll have to downgrade your client library version if you need to connect to a server using old password authentication.

You could also try pymysql instead of MySQLdb, which should still have support for old password hashes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download