Back Up your ClearDB And Restore In Azure Virtual Machine MySQL

This article explains how you can back up and restore your clear db MySQL database in a virtual machine in Azure.

This article explains how you can back up and restore your clear DB MySQL database in a virtual machine in Azure.

If you are new to azure, I recommend you to read here.

Background

I hope you read my articles related to Virtual Machines in azure. If not, please read those. I was being limited to use only 20 MB size since one of the MSDN subscription was providing me ClearDB. So I thought of creating a virtual machine and install MySQL. Then I restored my previous database to my new database. Here in this article, I will share you the steps to back up and restore your database.

Please read this article in my blog here

Steps to Back Up your ClearDB and restore

Login to your azure portal.

Login to your Azure Virtual Machine.

Hope you have already installed MySQL in your Virtual Machine. If so, we are ready to go.

Go to start menu, and type MySQL, you will be shown some results. Click on the MySQL command line section.
Back Up your ClearDB and restore in Azure Virtual Machine MySQL

Provide your MySQL password.

Back Up your ClearDB and restore in Azure Virtual Machine MySQL

You will be getting a welcome message as in the following screenshot:

Back Up your ClearDB and restore in Azure Virtual Machine MySQL

Create a database by executing a query as in the following screenshot:

Back Up your ClearDB and restore in Azure Virtual Machine MySQL

Go to start again, type cmd, right click and run as administrator on the result as follows.

Back Up your ClearDB and restore in Azure Virtual Machine MySQL

Go to MySQL bin folder by executing the commands as in the following screenshot:

Back Up your ClearDB and restore in Azure Virtual Machine MySQL

Before going through the back up process, we need to make sure that our website related files can be opened with on-line visual studio.

For that you need to follow the below steps.

Go to your windows azure portal, click on the web application you need to edit. Once you done that, you can see the dashboard for that web application. Click on CONFIGURE.

Back Up And Restore Your Old MySQL Database to New

Scroll down and switch on edit in visual studio on-line option.

Back Up And Restore Your Old MySQL Database to New Database

Now if you go to the options given in the area of your dashboard, you can see edit in visual studio on-line option.
Back Up And Restore Your Old MySQL Database to New Database

Just click on that option and it will open visual studio on-line with your application files.

Back Up And Restore Your Old MySQL Database to New Database

Now go back to your command prompt in your virtual machine and type a command as follows.

Back Up And Restore Your Old MySQL Database to New Database

In the above command, what we do is, creating back up from our old database to a new file. Make sure that you have given the correct details.

  1. User Name
  2. Host Name
  3. Database Name 

These information you can get from the wp-config.php file from your web application folder. Remember we have enabled open with visual studio on-line option? Please go back to that and copy the needed information from wp-config.php file.

So once you execute that command you can get a script file in your c folder, In my case I gave the path as C and the file name as myolddb. So I got the script file as in the following screenshot:

Back Up And Restore Your Old MySQL Database to New Database

The next thing we need to do is, restoring the back up to our new database, right? Hope you already got back up file.

Go to the command prompt again. Type the command as follows.

Back Up And Restore Your Old MySQL Database to New Database

Please be noted that you need to give your new username you have created for your new MySQL database and the new database name here.

In my case vmmysqluser was the username and sibeeshpassion is the database name.

Now it is time to check the database is restored or not. We have some set of queries for that.

Firstly, change the database to your new database.

  1. use yournewdatabasename;  
When you run the above query, you will get a message saying database changed.
  1. show tables;  

Now we will see the tables inside this new database.

It will result the list of tables inside this new database.

Back Up And Restore Your Old MySQL Database to New Database

So we have successfully done back up and restoring our MySQL database in azure virtual machine.

Conclusion

Did I miss anything that you may think which is needed?. Have you ever tried virtual machine in azure?. If not, I strongly recommend that. Is this post helped you do back and restore your old database to new one? I hope you liked this article. Please share me your valuable suggestions and feedback.

Your turn. What do you think?

A blog isn’t a blog without comments, but do try to stay on topic. Write your questions in the comment section below.