×
Community Blog How to Create a MySQL Backup and Migrate a Database to Alibaba Cloud

How to Create a MySQL Backup and Migrate a Database to Alibaba Cloud

The article covers two methods to create a MySQL backup and transfer a database to Alibaba Cloud: using the mysqldump utility and dbForge Studio for MySQL.

Alibaba Cloud is now ranking No. 3 infrastructure as a service provider in the world, trailing only AWS and Microsoft Azure. In the Asia-Pacific region, Alibaba Cloud boasts a strong lead on the market of cloud providers. More and more businesses are moving to Alibaba Cloud because of its cost-effectiveness, top performance, and high availability. In this tutorial, we provide a detailed overview of two ways to migrate an open source MySQL database to ApsaraDB RDS Alibaba Cloud database service.

Essentially, the process of moving a database to an ApsaraDB RDS is pretty much similar to moving a database from one server to another. Let’s look at two simple ways to perform it.

Back up and restore a database on ApsaraDB RDS with mysqldump Back up and restore a database on ApsaraDB RDS with dbForge Studio for MySQL

Back up and restore a MySQL database on ApsaraDB RDS with mysqldump


The mysqldump client utility is used primarily for performing logical backups. With its help, you can dump one or more MySQL databases and move them to another server. mysqldump supports a bunch of useful database management operations, however, in this article, we will focus exclusively on its backup capabilities.


Prerequisites


1. This tutorial assumes that you have already created an Alibaba Cloud account.

2. This tutorial assumes that you have already created ApsaraDB RDS for MySQL instance, configured IP address whitelist, and obtained a public endpoint.

For more information, refer to Sign up with Alibaba Cloud.

Workflow to create a MySQL backup and then restore a database with mysqldump

Step 1. Open Command Prompt, navigate to the directory where mysqldump is installed, and run the  mysqldump command. Usually, the utility is located in the MySQL Server installation folder, and the path to it is as follows: C:\Program Files\MySQL\MySQL Server 8.0\bin\


Step 2. Create a MySQL backup. 

To create a MySQL database backup, run the command:
mysqldump --user root --password [db_name] > [db_name].sql


For example, let’s dump the nation database that is stored at our local MySQL Server. The command for this will look like as follows:

mysqldump -h 127.0.0.1 -u root -p --opt --default-character-set=utf8 --hex-blob nation --skip-triggers --skip-lock-tables > D:\Backup\nation.sql

GAvUeFQPPa82nRH-3K25CXLT_TCWj7W65ldinzvv


Step 3. Connect to ApsaraDB RDS instance and create an empty database.

Run the MySQL Command Line Tool, connect to the ApsaraDB RDS instance, and create an empty database as shown in the picture below.

zLHvpXG_7VQf6NFuSIc-On0o7l2sNPBVSqbNGAdO


Step 4. Using mysqldump, restore the database from the backup you have created earlier. The command for restoring a database is given below. After mysqldump asks for a password, provide it.

 mysql -u [user] -p [database_name] < [filename].sql


In our guide, we run the following command to restore the MySQL nation database on ApsaraDB RDS.

mysql -h rm-4xo7kd5l1k993t1tnoo.mysql.germany.rds.aliyuncs.com -P 3306 -u root -p nation < D:\Backup\nation.sql

P5V4TbiNnyXe58KWgKAKWbxsrU_pAJfN4ipuAvuZ

The operation has been successful, and the database has been restored. We can check this by using the SHOW TABLES; command.

grUe09ubD7yGlhCdWOn1rK4mp5DbXH1m1b-vFwS1


As you can see, the database is no longer empty. Let’s now look at the ApsaraDB RDS console. The nation database has appeared on the Databases tab.

venSkPUWUQyu9i7ftMzB3Bxwkc-BIlgxj4y-wXy_


For more information on how to perform DB backups, please refer to Different Ways to Back up MySQL Databases and Tables.



Create a MySQL backup and restore a database on ApsaraDB RDS with dbForge Studio for MySQL


dbForge Studio for MySQL is an all-in-one GUI solution for developing, managing, and administering MySQL and MariaDB databases. It provides a simple visual way to back up and restore a database on Alibaba Cloud just in a few clicks.

In this tutorial, we will demonstrate how to migrate the world database from localhost to Alibaba Cloud ApsaraDB RDS.

Prerequisites

1. The tutorial assumes that you have created an Alibaba Cloud account.

2. The tutorial assumes that you have already created ApsaraDB RDS for MySQL instance, configured IP address whitelist, and obtained a public endpoint.

4. To be able to use the backup and restore functionality of dbForge Studio for MySQL, download and install the tool.

Workflow

Step 1. Create a database backup.

To create a DB backup with dbForge Studio for MySQL, right-click the required database in Database Explorer and select Backup and Restore > Backup Database.

k3oLO3AkzFwvydKTu7CcFPFndwRMJVq9AjvrnuLA


In the Database Backup Wizard that opens, provide a path to the directory to save the backup file and click Next.

JTG2H_vVGdW0I9HngUGZLqmhn2hd_RQh0oO0F59Z


On the Backup content tab, select database objects to back up and click Next.

OY1F2qVVyIdvRVe5iG_z50_hbIhrVjAbquIheXHn


On the Options tab, specify the backup options and click Next.

4_cXlmEjbl_sRPTLq9gX5umy9ddDf6MxHmGKP-cV


On the Errors handling tab, configure errors processing behavior and logging options. Click Backup to perform the backup operation.

d9vhJ2t9jVB-69krEcVjSFzAPwuqlZse9p8gyxHr


Step 2. Connect to the ApsaraDB RDS instance.

To connect to the ApsaraDB RDS instance, on the Database menu, click New Connection. In the Database Connection Properties dialog that opens, configure the connection properties and click Connect.

v_CxC8vgEs2v73WgkD8nkAGqk3yU3XN-jNs8jXYv


Step 3. Create an empty database on Alibaba Cloud ApsaraDB RDS.

To create a database in dbForge Studio for MySQL, on the Database menu, click New Database. On the Create database page that opens, provide a name for a new database, specify its character set and collation, and click Apply changes.

We8vh1xAv_oc8SARUQHz9mAYI4mdz979BeZXlEyG


Step 4. Restore a database on Alibaba Cloud ApsaraDB RDS.

To restore a database with dbForge Studio for MySQL, right-click the empty database in Database Explorer and select Backup and Restore > Restore Database.

In the Database Restore wizard that opens, select the file to restore the database from and click Restore.

Ng3TP7gLKKjfJoP5xv-M7oRuZLZQ4SUmkCZT0k8c


Let’s now check the ApsaraDB RDS console. As you can see, the world database has appeared in the list of databases.

gW3FSsuvPAUvU4Pqg8A94Fs7i24nc09BOQAvwD7k


Let’s check the Studio too. The world database is now listed in Database Explorer, and the database data has remained intact. Our efforts have been successful.

gaMEpCNK_PzGOMm0V1pHBbw3km0sOYKdHIxmXz5k


Conclusion

Unlike mysqldump, dbForge Studio for MySQL lets you migrate a database from MySQL or MariaDB Server to Alibaba Cloud with little to no effort. You don’t need to memorize complex commands and enter them manually from the command line. Instead, the Studio delivers a visual, intuitive way to back up and restore a database in a couple of clicks. More than that, you don’t need to back up your entire database⁠—just select database objects to be included in your backup file. And that's not to mention the fact that the Studio allows you to schedule backup and restore operations as well as other routine tasks from the command line. 


After all, a picture is worth a thousand words, so download dbForge Studio for MySQL and get a FREE 30-day fully-functional trial to be able to evaluate all the advanced features it delivers.


frameLabelStart-//www.youtube.com/embed/DD06e9XMTow" width="640" height="360" class="note-video-clip-frameLabelEnd
0 0 0
Share on

AlenaS

3 posts | 0 followers

You may also like

Comments

AlenaS

3 posts | 0 followers

Related Products