This topic describes how to restore a database through logical backup files. You can use the mysqldump utility that comes with MySQL to restore a database through logical backup files.
- For more information about how to restore physical backup files to on-premises databases, see Restore data from physical backup files of ApsaraDB for MySQL to an on-premises user-created database.
- For more information about how to back up ApsaraDB RDS for MySQL data, see Back up the data of an RDS instance.
The on-premises MySQL database is installed in a 64-bit Linux system. The version of the database is the same as that of the ApsaraDB RDS for MySQL instance. This topic describes how to restore data from logical backup files of an ApsaraDB RDS for MySQL 5.7 instance running the Linux 7 system.
- MySQL 5.7 High-availability Edition (based on local SSDs)
- MySQL 5.6
- MySQL 5.5
- Log on to the ApsaraDB for RDS console.
- In the upper-left corner of the page, select the region where the target instance is located.
- Find the instance and click the instance ID.
- In the left-side navigation pane, click Backup and Restoration.
- Select a time range and click Search.
- In the backup list, find the backup file and click Download.
Note If Download does not appear, make sure that the version of your instance allows you to download logical backup files.
- In the Download Instance Backup Set dialog box that appears, click Copy External Download URL.
- Log on to the Linux system where the on-premises database resides and run the following
command to download the logical backup files:
wget -c '<External download URL>' -O <Custom file name>.tar.gzNote
- -c: specifies to resume from the breakpoint.
- -O: saves the downloaded results as a specified file.
- Run the following command to decompress the logical backup files, including the default
and user-generated database files:
tar xvf <Data backup file name>.tar
- Decompress the compressed files for the database to be restored.
gzip-d <Compressed database file name>.gz
- Log on to the on-premises database to create an empty database.
mysql -uroot -p<Database password> mysql> create database <Database name>; Query OK, 1 row affected (0.00 sec) mysql> exit Bye
- Run the following command to import the .sql file to the empty database:
mysql-uroot-p <Database password> <Empty database name> <~ /<Database name after decompression>.sql
- Log on to the database and check for table data. If table data exists, the migration is successful.