question

JamiPremKumar-7324 avatar image
0 Votes"
JamiPremKumar-7324 asked thetitan answered

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



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-machinesazure-database-mysql
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @JamiPremKumar-7324 Welcome to Microsoft, thanks for posting your query,
As we understand the ask here is you are trying to load the WordPress webpage and it throws a connection error with MySQL database, please correct me if I am wrong.

For the mentioned scenario you need to make changes in the wp-config file to use azure DB for MySQL server in your WordPress VM as mentioned in the below article Here

Regards
Geetha

0 Votes 0 ·

@GeethaThatipatri-MSFT Yes Geetha. It is throwing an error "Error establishing connection with the database"


I gave the below details in the wp-config.php file

Database account name
Database name
Username
Password

0 Votes 0 ·
GeethaThatipatri-MSFT avatar image
0 Votes"
GeethaThatipatri-MSFT answered GeethaThatipatri-MSFT commented

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for visiting the Microsoft QA forums! Have a great day!


Regards
Geetha

0 Votes 0 ·
thetitan avatar image
0 Votes"
thetitan answered

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 );
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.