Help Center/ GaussDB(for MySQL)/ User Guide/ Data Migration/ Migrating Data to GaussDB(for MySQL) Using the Export and Import Functions of DAS
Updated on 2024-09-24 GMT+08:00

Migrating Data to GaussDB(for MySQL) Using the Export and Import Functions of DAS

Scenarios

Data Admin Service (DAS) is a one-stop management platform that allows you to manage Huawei Cloud databases on a web console. It offers database development, O&M, and intelligent diagnosis, making it easy to use and maintain databases.

During data backup or migration, you can use data export of DAS to obtain complete data information and import the data from a local PC or OBS bucket to the target data table. DAS allows you to export an entire database, some data tables, or SQL result sets.

Constraints

  • Only one file that is no larger than 1 GB can be imported at a time.
  • Only data files in .sql, .csv, or .xlsx format can be imported.
  • If data files are exported as a .zip package, they cannot be directly imported. You need to extract the files first.
  • Binary fields such as BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB cannot be imported.
  • Data cannot be exported or imported using cross-region OBS buckets.

Exporting Data

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner of the page and choose Databases > GaussDB(for MySQL).
  4. On the Instances page, locate the target DB instance and click Log In in the Operation column.
  5. On the displayed DAS login page, enter the username and password and click Log In.
  6. On the top menu bar, choose Import and Export > Export.

  7. Export an entire database, some data tables, or SQL result sets.
  8. Export an entire database.

    Method 1: Use the quick export function to export data from a database.

    1. Click Quick Export and select the database to be exported.

    2. In the displayed dialog box, select a storage path and click OK.
      • DAS does not store any data. The exported data files are stored in the OBS bucket that you have created.
      • Creating an OBS bucket is free, but you will be billed for storing data in the bucket.

    Method 2: Create an export task to export data from a database.

    1. Click Create Task > Export Database.
    2. In the displayed dialog box, configure task information.

      Table 1 Parameter description

      Category

      Parameter

      Description

      Basic Information

      Database

      Select the database to be exported and select Export all tables.

      • You can also select Export from standby database as required. If this option is selected, DAS connects to your standby database to export data. This prevents the primary database from being affected by data export. However, if the standby database has a high replication delay, the exported data may not be the latest.
      • Databases are classified into user databases and system databases. System databases cannot be exported. If system database data is required, deploy system database services in a user database, so that you can export the system database data from the user database.

      Allowed Rows

      Select the maximum number of rows in a single table.

      File Type

      Select SQL, CSV, or EXCEL.

      Object to Export

      Select Data, Structure, or Data and structure.

      Charset

      Select UTF8 or GBK.

      Storage

      Select the OBS bucket for storing data files.

      Options

      • Combine INSERT statements.

        If you select this option, INSERT statements will be combined into files, with each file no greater than 5 MB.

      • Generate a file for each table.

        If you do not select this option, all data files will be exported as a .zip package, which cannot be directly imported. You need to extract the files first.

        If you select this option, the data file (in .sql, .csv, or .xlsx format) of each table will be exported and can be directly imported again.

      Remarks

      -

      Advanced Settings

      You can set advanced options as required.

    3. Click OK.

  9. Export some data tables.

    1. Click Create Task > Export Database.
    2. In the displayed dialog box, configure task information.

      Table 2 Parameter description

      Category

      Parameter

      Description

      Basic Information

      Database

      Select the database to be exported and select the tables to be exported in the Tables area on the right.

      You can also select Export from standby database as required. If this option is selected, DAS connects to your standby database to export data. This prevents the primary database from being affected by data export. However, if the standby database has a high replication delay, the exported data may not be the latest.

      Allowed Rows

      Select the maximum number of rows in a single table.

      File Type

      Select SQL, CSV, or EXCEL.

      Object to Export

      Select Data, Structure, or Data and structure.

      Charset

      Select UTF8 or GBK.

      Storage

      Select the OBS bucket for storing data files.

      Options

      • Combine INSERT statements.

        If you select this option, INSERT statements will be combined into files, with each file no greater than 5 MB.

      • Generate a file for each table.

        If you do not select this option, all data files will be exported as a .zip package, which cannot be directly imported. You need to extract the files first.

        If you select this option, the data file (in .sql, .csv, or .xlsx format) of each table will be exported and can be directly imported again.

      Remarks

      -

      Advanced Settings

      You can set advanced options as required.

    3. Click OK.

  10. Export SQL result sets.

    1. Click Create Task > Export SQL Result.
    2. In the displayed dialog box, configure task information.

      Table 3 Parameter description

      Category

      Parameter

      Description

      Basic Information

      Database

      Select the database to be exported.

      You can also select Export from standby database as required. If this option is selected, DAS connects to your standby database to export data. This prevents the primary database from being affected by data export. However, if the standby database has a high replication delay, the exported data may not be the latest.

      Allowed Rows

      Select the maximum number of rows in a single table.

      File Type

      Select SQL-Insert, CSV, or EXCEL.

      Charset

      Select UTF8 or GBK.

      Storage

      Select the OBS bucket for storing data files.

      Options

      • Combine INSERT statements.

        If you select this option, INSERT statements will be combined into files, with each file no greater than 5 MB.

      • Generate one file for each result.

        If you do not select this option, all data files will be exported as a .zip package, which cannot be directly imported. You need to extract the files first.

        If you select this option, the data file (in .sql, .csv, or .xlsx format) of each result set will be exported and can be directly imported again.

      SQL to Execute

      Enter an SQL statement.

      To export multiple SQL result sets at a time, enter multiple SQL statements, with each on a separate line and ending with a semicolon (;). After the export task is complete, SQL files are generated. One SQL statement corresponds to one file.

      Remarks

      -

      Advanced Settings

      You can set advanced options as required.

    3. Click OK.

Importing Data

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. On the Instances page, locate the target DB instance and click Log In in the Operation column.
  5. On the displayed DAS login page, enter the username and password and click Log In.
  6. On the top menu bar, choose Import and Export > Import.
  7. Click Create Task.
  8. In the displayed dialog box, configure task information.

    Table 4 Parameter description

    Parameter

    Description

    Import Type

    Set this parameter based on the type of an exported file. Currently, only SQL and CVS files are supported.

    File Source

    Import a file from your local PC or an OBS bucket.

    • Upload file

      If you select Upload file for File Source, you need to set Attachment Storage and upload the required file.

      To keep your data secure, provide your own OBS bucket to store the attachments you upload. In this way, DAS automatically connects to your OBS bucket for in-memory reading.

      Creating an OBS bucket is free, but you will be billed for storing data in the bucket.

    • Choose from OBS

      If you select Choose from OBS for File Source, you need to select a file from the bucket.

      The file uploaded from an OBS bucket will not be deleted upon an import success.

    Database

    Select the destination database.

    Charset

    Select UTF8, GBK, or Auto Detect.

    Options

    • Ignore errors, skip the step when the SQL statement fails to be executed.

      If you select this option, the system will skip any errors detected when SQL statements are being executed.

    • Delete the uploaded file upon an import success.

      If you select this option, the file you uploaded will be automatically deleted from the OBS bucket after being imported to the destination database. This option is only available to the files uploaded from your local PC.

    Remarks

    -

  9. Click Create.
  10. In the displayed dialog box, confirm the information and click OK.

  11. After the data is imported successfully, log in to the destination database to query the imported data.