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

Jami Prem Kumar 31 Reputation points
2022-03-15T12:08:25.77+00:00

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
    2022-04-03T21:22:39.497+00:00

    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.

    Regards
    Geetha

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Alexandar Tzanov 11 Reputation points
    2022-05-16T20:58:17.233+00:00

    Hi,

    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 );
    define( 'MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL );
    
    2 people found this answer helpful.