Unable to connect to my MYSQL Azure from my Webapp - 1045, "Access denied for user 'dbadmin'@'xx.xx.xx.x' (using password: YES)

1.9k views Asked by At

I keep receiving the following error in my Webapp

OperationalError: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'dbadmin'@'xx.xx.xx.x' (using password: YES)")

MySQL Azure:

  • Hosted in Region > France Central
  • Allowed Access to Azure Services
  • Created through Azure portal with username "dbadmin" and server "jetbase"

SQLAlchemy db_uri looks like this

mysql://dbadmin@jetbase:'mysecretpassword'@jetbase.mysql.database.azure.com:3306/jetdb

Webapp:

Hosted in France Central as well

The same docker image when run locally on my dev computer, can access the database (I manually added the ip in the client IP addresses under Security.)

Can someone please help me debug this ?

2

There are 2 answers

0
Laurent Payet On

I can give 2 ideas, with the provided information :

  • the encoding of database URL in your web app client. We have similar DB url syntax (with "@" in username) for our PG instances. In our servers, we replaced it with "%40" for it to work.
  • account dbadmin is not allowed from you webserver IP (maybe the IP is not static, maybe it is not the one you think of, it really depends on the hosting of your webapp). I imagine you double checked that already.

We can try debugging together if you want at StationF

1
Shankar ARUL On

Here's the wierd thing, my password had an exclamation mark '!' and turns out it wasnt getting parsed properly and I kept getting the error 'Access denied for [email protected] (Password = yes)

I switched it to a "*" and it works fine now.

I also had to remove the single quotes around the password from the db_uri

mysql://dbadmin@jetbase:[email protected]:3306/jetdb

Ps: The strange thing is that, the same docker container when run locally on my computer with the password containing a !, works fine. it works from MySQL work bench as well but just fails from App services (webapp) in Azure. I'm guessing Azure App services encodes the db_uri and messes up the "!" in the password