I have an azure app service, using the latest wordpress image from docker hub. The screenshot for the azure app service:
Then in the azure app service -> application setting, I added the following key/value pairs which will be used to connect Azure database for mysql:
- WORDPRESS_DB_HOST
- WORDPRESS_DB_NAME
- WORDPRESS_DB_PASSSWORD
- WORDPRESS_DB_USER
Inside my Azure database for mysql, I have enabled public access / allow public access from any azure service / also add my client ip and this ip range 0.0.0.0 – 255.255.255.255. I can access it from my client and create the database which will be used by azure app service. Screenshot like below:
in server parameters, I also turn off the require_secure_transport setting:
At last, I tried to launch the site, but it throws the error "Error establishing a database connection", screenshot below:
I’m new to wordpress / docker, and don’t know how to fix this issue. I also reviewed some videos / docs, and didn’t see any other configuration differences. Could you please guide me how to fix this issue? Thanks very much.
2
Answers
You received this error message.
It means MySQL received, processed, and rejected your WordPress instance’s attempt to connect. So you know the hostname is right and your cloud provider’s firewall settings allow your WordPress instance to exchange network data with your MySQL instance.
What’s wrong?
MySQL’s user name / account name setup has a quirk. An account name can look like
'ivan'@'localhost'
or'ivan'@'%'
(or even something like'ivan'@'192.0.22.33'
).The first of those only allows login from localhost (or via tunneling via ssh). The second allows login from
'%'
, meaning any host. You need the second one for your WordPress instance to get access to MySQL.When you’re logged in to MySQL from your machine, do this.
You should see two rows, like these
It’s possible the account with
'%'
as the host is missing. If so that means you need to create another MySQL account and give it access to your database. Do that like this.Next, make sure the user account you just created — the one your WordPress software will use to connect to MySQL — has access to your database.
If you still get the error message, it’s possible the password on your
'ivan'@'%'
account doesn’t match what you put into your WordPress configuration. You can change it withIf it still gives the same error message, it’s possible that your cloud vendor requires TLS to connect to MySQL. You may want to consult their support team about that.
(This is a common stumbling block setting up new WordPress instances.)
ok just to keep and make things clear. all IPs can connect to the DB but are you actually authorized to read/write date in the DB?
I.E. this might be a permission/privilege issue.
I suggest double checking user privileges and determine who can do what on your DB
Best Regards. 🙂