how to connect azure mysql database to wordpress on azure vm?

Jami Prem Kumar 31 Reputation points

I tried setting up a WordPress website on Azure Virtual Machine.
Instead of installing MySQL DB. I tried creating an Azure DB for MySQL (Flexible Server) in the same network with the private access and gave the database details in the wp-config.php file in the server.

While loading the webpage with the IP Address in the browser. I am receiving "Error establishing connection with database"

Can you please help me resolve this.

OS: Linux
apache and php used.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,281 questions
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
726 questions
{count} vote

Accepted answer
  1. GeethaThatipatri-MSFT 27,972 Reputation points Microsoft Employee

    Hi @ JamiPremKumar-7324 As per the support team this issue has been resolved after disabling the SSL Connection setting for the server parameter and WordPress website on Azure Virtual Machine is working as expected.


    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Alexandar Tzanov 11 Reputation points


    I have a similar setup: WordPress is running on a Linux VM and MySQL is setup in an Azure DB for MySQL (Flexible Server).

    You do NOT have to disable traffic encryption between your DB and web servers. You want data to be secure in transit.

    WordPress can handle SSL connections to a database. To enable this, add the following lines in your "wp-config.php" file.

    define( 'DB_SSL', true );
    2 people found this answer helpful.