Este conteúdo foi traduzido por máquina para sua conveniência e a Huawei Cloud não pode garantir que o conteúdo foi traduzido com precisão. Para exibir o conteúdo original, use o link no canto superior direito para mudar para a página em inglês.
Computação
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Redes
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Gerenciamento e governança
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
Cloud Operations Center
Resource Governance Center
Migração
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Análises
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
IoT
IoT Device Access
Outros
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Segurança e conformidade
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Blockchain
Blockchain Service
Serviços de mídia
Media Processing Center
Video On Demand
Live
SparkRTC
Armazenamento
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Cloud Server Backup Service
Storage Disaster Recovery Service
Scalable File Service
Volume Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Bancos de dados
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Aplicações de negócios
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Data Lake Factory
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Distribuição de conteúdo e computação de borda
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Soluções
SAP Cloud
High Performance Computing
Serviços para desenvolvedore
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
Cloud Application Engine
MacroVerse aPaaS
KooPhone
KooDrive
Central de ajuda/ TaurusDB/ Guia de usuário/ Migração de dados/ Migrating Data to TaurusDB Using mysqldump

Migrating Data to TaurusDB Using mysqldump

Atualizado em 2025-02-07 GMT+08:00

Mysqlpump is not recommended because it can result in a core dump in parallel backup scenarios. Mysqldump is recommended instead.

Preparing for Data Migration

You can access a TaurusDB instance through a private network or a public network.

  1. Prepare an ECS in the same VPC and subnet as the TaurusDB instance or bind an EIP to the TaurusDB instance.
    • To connect to an instance through a private network, an ECS has to be created first.

      For details on how to create and log in to an ECS, see descriptions about creating an ECS and logging in an ECS in the Elastic Cloud Server User Guide.

    • To connect to an instance through an EIP, you must:
      1. Bind the EIP to the instance.
      2. Ensure that the local device can access the EIP that has been bound to the instance.
  2. Install the MySQL client on the prepared ECS or device.

    The MySQL client version must be the same as or later than that installed on the TaurusDB instance. The MySQL database or client provides the mysqldump and mysql tools by default.

Exporting Data

Before migrating data to TaurusDB, data needs to be exported first.

  • The export tool must match the DB engine version.
  • Database migration is performed offline. Before the migration, you must stop any applications using the source database.
  1. Log in to the prepared ECS or device that can access the TaurusDB instance.
  2. Use mysqldump to export the metadata into an SQL file.

    MySQL databases are required for TaurusDB management. When exporting metadata, do not specify --all-database, or the databases will be unavailable.

    mysqldump --databases <DB_NAME> --single-transaction --order-by-primary --hex-blob --no-data --routines --events --set-gtid-purged=OFF -u <DB_USER> -p -h <DB_ADDRESS> -P <DB_PORT> |sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' -e 's/DEFINER[ ]*=.*FUNCTION/FUNCTION/' -e 's/DEFINER[ ]*=.*PROCEDURE/PROCEDURE/' -e 's/DEFINER[ ]*=.*TRIGGER/TRIGGER/' -e 's/DEFINER[ ]*=.*EVENT/EVENT/' > <BACKUP_FILE>

    • DB_NAME indicates the name of the database to be migrated.
    • DB_USER indicates the database username.
    • DB_ADDRESS indicates the database address.
    • DB_PORT indicates the database port.
    • BACKUP_FILE indicates the name of the file to which the data will be exported.

    Enter the database password when prompted.

    Example:

    mysqldump --databases gaussdb --single-transaction --order-by-primary --hex-blob --no-data --routines --events --set-gtid-purged=OFF -u root -p -h 192.xx.xx.xx -P 3306 |sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' -e 's/DEFINER[ ]*=.*FUNCTION/FUNCTION/' -e 's/DEFINER[ ]*=.*PROCEDURE/PROCEDURE/' -e 's/DEFINER[ ]*=.*TRIGGER/TRIGGER/' -e 's/DEFINER[ ]*=.*EVENT/EVENT/' > dump-defs.sql

    Enter password:

    After this command is executed, the dump-defs.sql file will be generated.

  3. Use mysqldump to export the data into an SQL file.

    MySQL databases are required for TaurusDB management. When exporting metadata, do not specify --all-database, or the databases will be unavailable.

    mysqldump --databases <DB_NAME> --single-transaction --hex-blob --set-gtid-purged=OFF --no-create-info --skip-triggers -u <DB_USER> -p -h <DB_ADDRESS> -P <DB_PORT> -r <BACKUP_FILE>

    For details on the parameters in the preceding command, see 2.

    Enter the database password when prompted.

    Example:

    mysqldump --databases gaussdb --single-transaction --hex-blob --set-gtid-purged=OFF --no-create-info --skip-triggers -u root -p -h 192.xx.xx.xx -P 3306 -r dump-data.sql

    After this command is executed, the dump-data.sql file will be generated.

Importing Data

You can use a client to connect to the TaurusDB instance through an ECS or a device and then import the exported SQL files into that instance.

If the source database calls triggers, stored procedures, functions, or events, you must set log_bin_trust_function_creators to ON for the destination database before importing data.

  1. Import metadata into the TaurusDB instance.

    mysql -f -h <DB_ADDRESS> -P <DB_PORT> -u root -p < <BACKUP_DIR>/dump-defs.sql

    • DB_ADDRESS indicates the IP address of the TaurusDB instance.
    • DB_PORT indicates the port of the TaurusDB instance.
    • BACKUP_DIR indicates the directory where dump-defs.sql will be stored.

    Example:

    mysql -f -h 172.xx.xx.xx -P 3306 -u root -p < dump-defs.sql

    Enter password:

  2. Import data into the TaurusDB instance.

    mysql -f -h <DB_ADDRESS> -P <DB_PORT> -u root -p < <BACKUP_DIR>/dump-data.sql

    • DB_ADDRESS indicates the IP address of the TaurusDB instance.
    • DB_PORT indicates the port of the TaurusDB instance.
    • BACKUP_DIR indicates the directory where dump-data.sql will be stored.

    Example:

    mysql -f -h 172.xx.xx.198 -P 3306 -u root -p < dump-data.sql

    Enter password:

  3. Use the MySQL tool to connect to the instance and view the result.

    mysql> show databases;

    In this example, the database named my_db has been imported.

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | my_db              |
    | mysql              |
    | performance_schema |
    +--------------------+
    4 rows in set (0.00 sec)

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Conteúdo selecionado

Envie o conteúdo selecionado com o feedback