You know this feeling when something that should take an hour finally take a day? That’s what happens to me when I tried to move my database from ClearDb (because it’s no longer included in the MSDN subscription). I wanted to use the free MySQL in App instance instead, and I wasn’t able to find a simple and complete guide for that. Hopefully this one will avoid some pain to some people.
About ClearDb and MySQL in App
ClearDb is a Saas service for MySql database. They used to host the WordPress azure app service. But now we have to pay for it as it’s no longer included in the MSDN subscription. An alternative is to use the free MySQL in App database provides by azure with app services. Beware that this Database is normally for testing purpose, they are not recommended for production. But for a WordPress site hosting a blog like mine, I think we should be fine.
Let’s save everything
The first action to do is to save your website (Just in case :)):
YourApp -> Settings -> Backup
The second action to do is to save your Data from ClearDb. The easiest way I found was to activate MySQL In App:
YourApp -> Settings -> MySQL In App
Click on “activate”. Then you would be able to click on “manage” in the upper left corner. It will open your php MyAdmin UI for your web app. You normally have (at least) two server available in the server list in the upper left corner. One is for your ClearDb database, the other one is for the localDb from your MySql In App.
You can select the ClearDb server, select your WordPress database, and use the export button to get a sql script from your DB schema and Data.
Now you can select the MySQL In App server (localhost), and use the existing localDb, then import the sql script that you get from the ClearDb database.
Reroute WordPress to the new Database
Last but not least, you need to change the wp-config file from the WordPress site to use the new MySqlApp database.
Go to https://[yourwebsite].scm.azurewebsites.net/ to see your Kudu UI. Using the Debug console, you will find your wp-config file in: D:\home\site\wwwroot.
You need to change the following values:
define('DB_NAME', ‘localdb’); define('DB_USER', ‘azure’); define('DB_PASSWORD', 'password’); define('DB_HOST', ‘127.0.0.1:port’);
To know the value for the connection you can check the ConnectionString for the My SQL App in D:\home\data\mysql\MYSQLCONNSTR_localdb.txt
It should looks like this:
Database=localdb;Data Source=127.0.0.1:port;User Id=azure;Password=password
Just extract your database name, user id, data source (host) and password.
Note that you need to precise the port for the host.
You can now remove the ClearDb connection string from the app service:
Settings -> application settings, connection strings
And of course stop your potential ClearDb subscription!
Hope it helps.