skip to Main Content

I have an azure app service, using the latest wordpress image from docker hub. The screenshot for the azure app service:
enter image description here

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:

  1. WORDPRESS_DB_HOST
  2. WORDPRESS_DB_NAME
  3. WORDPRESS_DB_PASSSWORD
  4. WORDPRESS_DB_USER

screenshot:
enter image description here

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:
enter image description here

in server parameters, I also turn off the require_secure_transport setting:
enter image description here

At last, I tried to launch the site, but it throws the error "Error establishing a database connection", screenshot below:
enter image description here

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


  1. You received this error message.

    Warning: mysqli_real_connect(): (HY000/1045)>: Access denied for user ‘ivan’@’52.xx.xxx.xx’ (using password: YES)

    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.

    SELECT host, user FROM mysql.user WHERE user='ivan';
    

    You should see two rows, like these

     host       user  
     ----       ---   
     %          ivan  
     localhost  ivan 
    

    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.

    CREATE USER 'ivan'@'%' IDENTIFIED BY 'your_password';
    FLUSH PRIVILEGES;
    

    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.

    GRANT ALL PRIVILEGES ON wordpress.* TO 'ivan'@'%';
    FLUSH PRIVILEGES;
    

    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 with

    ALTER USER 'ivan'@'%' IDENTIFIED BY 'your_password'; 
    FLUSH PRIVILEGES;
    

    If 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.)

    Login or Signup to reply.
  2. 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. 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search