Azure Database for MySQL grabbed the attention of developers and they had shown a remarkable interest in it. Better and efficient features of Azure Database for MySQL distinguish it from other databases and people want to know how to migrate a web app from ClearDB to Database Azure. Here, I will provide the right migration method and will use a WordPress website database from DB to Azure Database for MySQL as an example.
Things You Need for Migration:
Both CLI and MySQL Workbench can be used for the migration and even you can use an alternative tool if you like. I have opted for MySQL Workbench due to the quick connection it builds to ClearDB database which is required after the downloading and installation of Workbench.
Go to Azure portal and click on Properties option to setup a MySQL Workbench connection. Click on the +icon after opening the MySQL Workbench. You will find the +icon at the top of the home screen.
Choose a unique name for your connection in Setup New Connection window. Here, you need some information about your browser, such as HOSTNAME, USERNAME, and PASSWORD. Switch to your browser and copy the required information. Don’t forget to click on the “Store in Vault” button to store the password in MySQL Workbench.
Another connection is required for Azure Database for MySQL and you have to repeat the same above mentioned process. In the case of no Azure Database for MySQL, you should follow the procedure of Quickstart. Configure the control access to Azure Database for MySQL server before entering Password, HOSTNAME, and other information.
Go to Azure Portal, find Connection Security in the left negation pane, and now click on it. Click on the Enforce SSL Connection to Disable the SSL connectivity to avoid unnecessary interruption. Now Add local IP to the firewall by clicking on the +Add My IP icon. You can also add up all IPs if you have created any firewall rules which you can remove afterward. Check the data present in documentation to configure SSL connectivity to the server.
By following the above-mentioned method, you can create as many MySQL Workbench connections as you are required. Check the main essential dashboard which you can access by opening Azure Database for MySQL server. On the main page, you can see Server Name and Server admin login name but the entered password can’t be shown to ensure your privacy. In case you forget your password, you can reset it anytime from Reset Password option that is present in the “Essential” pane.
Migrate Your Database:
To migrate your database, open MySQL Workbench and click on Database next to View option. In the dropdown menu, Migration Wizard option is present where you need to choose source and target database servers. Choose the connection you prior created and for the destination you need to click Azure Database for MySQL Server.
Only migrate the schema in your application. Don’t try to change the random name created by the ClearDB. Moreover, don’t migrate your database too long and prefer to transfer it in the same region as source ClearDB database.
Configuring Your Azure Web App:
After the successful migration of database, you need to make a connection between Web App and Azure Database for MySQL. Open your app in the Azure portal and select Properties to notedown the Outbound IP Addresses.
The next step is the creation of firewall rules for each IP address as the IP addresses of firewalls are different from each other. Open the Application Settings in Azure Web App and click on the Connection Strings. Modify the connection string to make the new server. Change all the values by simply clicking on the string value. The connection string which I found is as following:
Database=acsm_8cb9eb8d372ebbd;Data Source=us-cdbr-azure-west-b.cleardb.com;User Id=b8c2e429e67ac2;Password=47bd9069
Similarly, the final form after updating the Azure Database for MySQL is like this:
Database=acsm_8cb9eb8d372ebbd;Data Source=jasonsnewserver.mysql.database.azure.com;User [email protected];Password=MyPassword12
Don’t forget to press the “Save” button to commit all the changes.