DalSoft / dalsoft-website-comments

0 stars 0 forks source link

blog/index.php/2016/09/30/in-app-mysql-for-web-apps-and-migrating-your-wordpress-blog-to-azure/ #23

Open utterances-bot opened 2 months ago

utterances-bot commented 2 months ago

In-app MySQL for Web Apps and migrating your WordPress blog to Azure | DalSoft Ltd

How we migrated our WordPress blog to Azure using the new In-app MySQL for Web Apps feature.

https://www.dalsoft.co.uk/blog/index.php/2016/09/30/in-app-mysql-for-web-apps-and-migrating-your-wordpress-blog-to-azure/

DalSoft commented 2 months ago

Legacy Comments

borrie says: November 24, 2016 at 12:16 pm Hey,

Thanks a lot for the tutorial!

It works but when i try to goto wp-admin it says it can’t find the db on that port. Do you know what this could be?

Borrie


borrie says: November 24, 2016 at 1:25 pm Hey,

Got it working completely in the meantime.

I think it’s best to drop the localdb, recreate it and then import your backup.

In the wp-config put this as your connection string in stead of the other:

/* Azure in APP MySQL */
$connectstr_dbhost = ”;
$connectstr_dbname = ”;
$connectstr_dbusername = ”;
$connectstr_dbpassword = ”;

foreach ($_SERVER as $key => $value) {
   if (strpos($key, “MYSQLCONNSTR_”) !== 0) {
      continue;
   }

   $connectstr_dbhost = preg_replace(“/^.*Data Source=(.+?);.*$/”, “\\1”, $value);
   $connectstr_dbname = preg_replace(“/^.*Database=(.+?);.*$/”, “\\1”, $value);
   $connectstr_dbusername = preg_replace(“/^.*User Id=(.+?);.*$/”, “\\1”, $value);
   $connectstr_dbpassword = preg_replace(“/^.*Password=(.+?)$/”, “\\1”, $value);
}

define(‘DB_NAME’, $connectstr_dbname);
define(‘DB_USER’, $connectstr_dbusername);
define(‘DB_PASSWORD’, $connectstr_dbpassword);
define(‘DB_HOST’, $connectstr_dbhost);

DalSoft says: December 12, 2016 at 3:37 pm Thanks for posting this, I just also hit a problem where MS have changed how in-app MySQL works so that it uses a different port/password on every app recycle. I used the same code as you have posted to fix it! I’ll update the post shortly to reflect this.