2

I am running into an issue where I am unable to connect to my RDS MySQL instance from my Flask app. I am using SQLAlchemy and everything is working locally but when I push my code to AWS I get the following error:

sqlalchemy.exc.OperationalError

OperationalError: (OperationalError) (1045, "Access denied for user 'db_user'@'xx.xx.xx.xxx' (using password: YES)") None None

Now I know for a fact that the error is not a security group issue as I am able to connect locally and on the instance using the MySQL client.

1 Answer 1

6

Well it turns out I wasn't doing anything wrong and this wasn't an error with AWS or Flask, it was strictly a SQLAlchemy bug! It turns out the URI format for MySQL connections is:

dialect+driver://username:password@host:port/database

My bug came from the fact that my password with a plus (+) character in it thus fooling the URI format into thinking everything before it was the dialect. Using a '+' character is completely legal for MySQL passwords and thus why connecting via the MySQL client was working. I hope anyone else with this error is able to find this and not spend as much time as I did trying to find a solution!

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

Comments

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.