7

I used to connect to my AWS-RDS instance this way

import MySQLdb

db = MySQLdb.connect(host=os.getenv('RDS_ENDPOINT'),
                     user=os.getenv('RDS_USER'),
                     passwd=os.getenv('RDS_PWD'),
                     db=os.getenv('RDS_DB'))

or with the help of sqlalchemy, but today it seem to refuse to work with the error (2006, 'SSL connection error: SSL_CTX_set_tmp_dh failed')

I tried to update all the python packages (mysqlclient, sqlalchemy), reinstall mysqlclient-dev, manually reinstall OpenSSL v1.1.1a but still the same error.

[EDIT]

I manage to connect to the same database using the MySQL CLI

mysql --user=$RDS_USER --host=$RDS_ENDPOINT --password=$RDS_PWD $RDS_DB

[SOLUTION]

It seems that this is a driver issue. I tried with mysqlclient for python 3 and got this error. Next I tried with mysql.connector as recommanded but I got encoding issues (as stated in the sqlalchemy doc). Finally, I ended with the pymysql driver which seems to work with sqlalchemy.

4
  • 1
    A driver issue? Are you sure you don't mean library? But indeed, switching to pymysql did the job for me too. Commented Jan 4, 2019 at 9:33
  • 2
    I faced the same issue when installed mysqlclient in anaconda environment. I uninstalled it "conda uninstall mysqlclient" and installed again with pip(pip install mysqlclient). It worked fine then. Commented Feb 19, 2019 at 11:57
  • This isn’t working for me and I can’t switch to pymysql because of issues with the in file query... does anyone have a solution? Commented Feb 21, 2019 at 20:41
  • Worked for me too!! Kudos!! Commented May 6, 2019 at 11:11

1 Answer 1

2

Upgrade mysqlclient package fixed the problem.

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

2 Comments

Thanks, It solved my problem too, you saved my time.
not working for me. I tried downgrading the openssl to 1.0.2r which is also not getting downgraded as it is conflicting with a package named protobuf. I've also asked regarding this problem but didn't got any answer: stackoverflow.com/questions/58958531/…

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.