Alexandar Tzanov's Personal Blog

Connect WordPress to Azure MySQL DB using a secure connection.

Few months back I decided to move Titan Fusion to Azure. I installed and configured an instance of WordPress on an Azure VM, but for security and performance reasons I decided to use an instance of Azure Database for MySQL to host the site’s database separately. After updating wp-config.php with the database configuration, WordPress was not able to connect to the remote database. After doing few tests and reviewing Microsoft’s documentation, I was able to determine that Azure database instances require a secure connection by default. There are ways to disable this requirement, but the better option is to simply tell WordPress to use a secure connection to the database. Especially when it is supported!

To enable secure database connections in WordPress simply add the lines below to your database configuration in the wp-config.php file.

/** Azure MySQL database requires SSL connection. */
define( 'DB_SSL', true );
define( 'MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL );

Don’t crimple you website’s security by disabling encryption just because it is on the backend or inconvenient. Data in transit should always be encrypted.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: