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.

Note

Precautions

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.

Prerequisites

The instance is in one of the following editions:
  • MySQL 5.7 High-availability Edition (based on local SSDs)
  • MySQL 5.6
  • MySQL 5.5

Procedure

  1. Log on to the ApsaraDB for RDS console.
  2. In the upper-left corner of the page, select the region where the target instance is located.
  3. Find the instance and click the instance ID.
  4. In the left-side navigation pane, click Backup and Restoration.
  5. Select a time range and click Search.
  6. 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.
  7. In the Download Instance Backup Set dialog box that appears, click Copy External Download URL.Download Instance Backup Set dialog box
  8. 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.gz
    Note
    • -c: specifies to resume from the breakpoint.
    • -O: saves the downloaded results as a specified file.
  9. 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
  10. Decompress the compressed files for the database to be restored.
    gzip-d <Compressed database file name>.gz
  11. 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
  12. 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
  13. Log on to the database and check for table data. If table data exists, the migration is successful.Log on to the database and check for table data