2
votes

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

1 Answers

6
votes

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!