Mantıksal yedeklemeler standart mysqldump dosyalarıdır. ApsaraDB RDS for MySQL örneğinden belirli veritabanlarını veya tabloları Linux üzerinde çalışan kendi yönettiğiniz bir MySQL veritabanına geri yüklemeniz gerektiğinde bu yöntemi kullanın. Bu kılavuz, yedeğin indirilmesini, sıkıştırılmasının açılmasını ve verilerin içeri aktarılmasını kapsar.
Belirli bir zamana göre geri yükleme işlemi için bunun yerine günlük yedeğiyle birlikte bir fiziksel yedekleme dosyası kullanın. Hangi yöntemin durumunuza uygun olduğundan emin değil misiniz? Veri geri yükleme yöntemlerine genel bakış konusuna bakın.
Nasıl çalışır
Mantıksal yedekleme dosyasını RDS konsolundan indirin.
.tararşivini ve ardından veritabanı başına oluşturulan.sql.gzdosyalarını açın.Boş bir hedef veritabanı oluşturun ve şema ile veri dosyalarını
mysqlkomutunu kullanarak içeri aktarın.
Ön koşullar
Başlamadan önce aşağıdakilere sahip olduğunuzdan emin olun:
-
Aşağıdaki özelliklerin tümüne sahip bir ApsaraDB RDS for MySQL örneği (Basic Information sayfasından kontrol edin):
Ana sürüm: 8,0, 5,7, 5,6 veya 5,5
Sürüm: High-availability Edition
Depolama türü: Local SSD
Zaten oluşturulmuş bir mantıksal yedekleme dosyası. Mantıksal yedeklemeler manuel olarak oluşturulmalıdır; sistem varsayılan olarak fiziksel yedeklemeler oluşturur. Bkz. Manuel yedekleme.
RDS örneğiyle aynı MySQL ana sürümünü çalıştıran ve açılmış yedekleme dosyalarını barındırmak için yeterli boş disk alanına sahip bir Linux ana bilgisayarı.
Bu kılavuzda örnekler için CentOS 7 ve MySQL 5,7 kullanılmaktadır.
Yedekleme dosyasını indirme
Go to the Instances page. In the top navigation bar, select the region where your RDS instance resides, then click the instance ID.
In the navigation pane on the left, click Backup and Restoration.
-
On the Base Backups > Data Backup tab, find the logical backup file you want to restore, then click Download Instance Backup File in the Actions column.
NotIf Download Instance Backup File is unavailable, check whether your instance edition supports backup downloads.
-
In the Download Instance Backup File dialog box, copy the download URL:
If your ECS instance and RDS instance are in the same VPC (recommended): copy the internal network URL. This is faster and more stable, especially for large backup files.
Otherwise: copy the external download URL. A free quota applies for internet backup downloads; traffic beyond the quota is charged. See Billing.
-
On the Linux host, run the following command to download the backup file. Replace
<download_url>with the URL you copied and<custom_file_name>with a name of your choice.Flag Description -cEnables resumable downloads, so the download resumes from where it stopped if interrupted -OSaves the file with the specified name wget -c '<download_url>' -O <custom_file_name>.tar
Decompress the backup file
-
Extract the
.tararchive:NotIf you see
This does not look like a tar archive, confirm that you downloaded an RDS logical backup file and not a physical backup. If you seeWrote only 512 of 10240 bytes, your disk is full — change the instance configuration to increase disk space, then try again.tar xvf <custom_file_name>.tar -C /tmp -
Check the directory structure after extraction. The archive contains one subdirectory per database, each with a schema file and a data file:
tree /tmp/backup_root/ # Replace with the actual root directory created by tar.Expected output:
/tmp/backup_root/ ├── database1/ # Directory of target database 1 │ ├── schema.sql # Database schema file │ └── data.sql # Data file ├── database2/ # Directory of target database 2 │ ├── schema.sql │ └── data.sql └── config.txt # Backup metadata (optional) -
Navigate to the directory of the database you want to restore:
cd /tmp/backup_root/<database_name> -
Decompress the
.sql.gzfiles:gzip -d schema.sql.gz gzip -d data.sql.gzThis produces
schema.sqlanddata.sql, which you will import in the next step.
Import the data
-
Log in to MySQL and create an empty target database. The user must have permission to execute all SQL statements in the
.sqlfiles.Placeholder Description Example <user>MySQL username root<password>MySQL password (no space after -p)mypassword<target_database_name>Name for the empty database to create restored_dbmysql -u <user> -p<password>CREATE DATABASE <target_database_name>; EXIT;Replace the placeholders as follows:
-
Import the schema and then the data:
NotIf you see
Can't find master key from keyring, your instance may not meet the prerequisites listed in this guide. Verify the RDS instance edition and storage type.# Import the table schema mysql -u <user> -p <target_database_name> < schema.sql # Import the data mysql -u <user> -p <target_database_name> < data.sqlEnter your password when prompted after each command.
Verify the restoration
-
Log in to MySQL and confirm that the tables and data are present:
mysql -u <user> -pUSE <target_database_name>; SHOW TABLES; -- Check that tables exist SELECT COUNT(*) FROM <table_name>; -- Verify the row countIf the tables and data appear, the restoration is complete.
FAQ
Why doesn't my instance have any logical backups?
RDS creates physical backups by default. To get a logical backup, create one manually. See Manual backup.
Why is the Restore Point in Time value 0 for logical backups?
Point-in-time restore requires a physical backup combined with a log backup. Logical backups do not support point-in-time restore, so the Restore Point in Time field shows 0.
How do I fix ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty?
This error means the target database already contains global transaction identifier (GTID) history. Use one of these approaches:
Enable GTID on the target database and re-run the import.
Comment out all
GTID_PURGEDlines in the.sqlfile and re-run the import.If primary/secondary replication is not in use, run
RESET MASTERon the target database to clear GTID history, then re-run the import.
How do I fix ERROR 3546 (HY000): @@GLOBAL.GTID_PURGED cannot be changed: the added gtid set must not overlap with @@GLOBAL.GTID_EXECUTED?
The .sql file contains GTID information that conflicts with existing GTID history in the target database. Run RESET MASTER to clear the GTID history, then re-run the import.

Why is the restored data only in the primary database and not synced to the secondary database?
The .sql file contains SESSION.SQL_LOG_BIN= 0, which disables binary logging during the import and prevents changes from replicating to the secondary database. Check the import file for this setting.

What's next
Back up an ApsaraDB RDS instance — set up automatic backups to make future restores easier.
Use mysqldump to migrate MySQL data — migrate data from a self-managed database into an RDS instance.
RDS MySQL mysqldump options — reference for all mysqldump flags supported by ApsaraDB RDS for MySQL.