- Docs Home
- About TiDB Cloud
- Get Started
- Develop Applications
- Overview
- Quick Start
- Build a TiDB Developer Cluster
- CRUD SQL in TiDB
- Build a Simple CRUD App with TiDB
- Example Applications
- Connect to TiDB
- Design Database Schema
- Write Data
- Read Data
- Transaction
- Optimize
- Troubleshoot
- Reference
- Cloud Native Development Environment
- Manage Cluster
- Plan Your Cluster
- Create a TiDB Cluster
- Connect to Your TiDB Cluster
- Set Up VPC Peering Connections
- Use an HTAP Cluster with TiFlash
- Scale a TiDB Cluster
- Upgrade a TiDB Cluster
- Delete a TiDB Cluster
- Use TiDB Cloud API (Beta)
- Migrate Data
- Import Sample Data
- Migrate Data into TiDB
- Configure Amazon S3 Access and GCS Access
- Migrate from MySQL-Compatible Databases
- Migrate Incremental Data from MySQL-Compatible Databases
- Migrate from Amazon Aurora MySQL in Bulk
- Import or Migrate from Amazon S3 or GCS to TiDB Cloud
- Import CSV Files from Amazon S3 or GCS into TiDB Cloud
- Import Apache Parquet Files from Amazon S3 or GCS into TiDB Cloud
- Troubleshoot Access Denied Errors during Data Import from Amazon S3
- Export Data from TiDB
- Back Up and Restore
- Monitor and Alert
- Overview
- Built-in Monitoring
- Built-in Alerting
- Third-Party Monitoring Integrations
- Tune Performance
- Overview
- Analyze Performance
- SQL Tuning
- Overview
- Understanding the Query Execution Plan
- SQL Optimization Process
- Overview
- Logic Optimization
- Physical Optimization
- Prepare Execution Plan Cache
- Control Execution Plans
- TiKV Follower Read
- Coprocessor Cache
- Garbage Collection (GC)
- Tune TiFlash performance
- Manage User Access
- Billing
- Reference
- TiDB Cluster Architecture
- TiDB Cloud Cluster Limits and Quotas
- TiDB Limitations
- SQL
- Explore SQL with TiDB
- SQL Language Structure and Syntax
- SQL Statements
ADD COLUMNADD INDEXADMINADMIN CANCEL DDLADMIN CHECKSUM TABLEADMIN CHECK [TABLE|INDEX]ADMIN SHOW DDL [JOBS|QUERIES]ALTER DATABASEALTER INDEXALTER TABLEALTER TABLE COMPACTALTER USERANALYZE TABLEBATCHBEGINCHANGE COLUMNCOMMITCHANGE DRAINERCHANGE PUMPCREATE [GLOBAL|SESSION] BINDINGCREATE DATABASECREATE INDEXCREATE ROLECREATE SEQUENCECREATE TABLE LIKECREATE TABLECREATE USERCREATE VIEWDEALLOCATEDELETEDESCDESCRIBEDODROP [GLOBAL|SESSION] BINDINGDROP COLUMNDROP DATABASEDROP INDEXDROP ROLEDROP SEQUENCEDROP STATSDROP TABLEDROP USERDROP VIEWEXECUTEEXPLAIN ANALYZEEXPLAINFLASHBACK TABLEFLUSH PRIVILEGESFLUSH STATUSFLUSH TABLESGRANT <privileges>GRANT <role>INSERTKILL [TIDB]MODIFY COLUMNPREPARERECOVER TABLERENAME INDEXRENAME TABLEREPLACEREVOKE <privileges>REVOKE <role>ROLLBACKSELECTSET DEFAULT ROLESET [NAMES|CHARACTER SET]SET PASSWORDSET ROLESET TRANSACTIONSET [GLOBAL|SESSION] <variable>SHOW ANALYZE STATUSSHOW [GLOBAL|SESSION] BINDINGSSHOW BUILTINSSHOW CHARACTER SETSHOW COLLATIONSHOW [FULL] COLUMNS FROMSHOW CREATE SEQUENCESHOW CREATE TABLESHOW CREATE USERSHOW DATABASESSHOW DRAINER STATUSSHOW ENGINESSHOW ERRORSSHOW [FULL] FIELDS FROMSHOW GRANTSSHOW INDEX [FROM|IN]SHOW INDEXES [FROM|IN]SHOW KEYS [FROM|IN]SHOW MASTER STATUSSHOW PLUGINSSHOW PRIVILEGESSHOW [FULL] PROCESSSLISTSHOW PROFILESSHOW PUMP STATUSSHOW SCHEMASSHOW STATS_HEALTHYSHOW STATS_HISTOGRAMSSHOW STATS_METASHOW STATUSSHOW TABLE NEXT_ROW_IDSHOW TABLE REGIONSSHOW TABLE STATUSSHOW [FULL] TABLESSHOW [GLOBAL|SESSION] VARIABLESSHOW WARNINGSSHUTDOWNSPLIT REGIONSTART TRANSACTIONTABLETRACETRUNCATEUPDATEUSEWITH
- Data Types
- Functions and Operators
- Overview
- Type Conversion in Expression Evaluation
- Operators
- Control Flow Functions
- String Functions
- Numeric Functions and Operators
- Date and Time Functions
- Bit Functions and Operators
- Cast Functions and Operators
- Encryption and Compression Functions
- Locking Functions
- Information Functions
- JSON Functions
- Aggregate (GROUP BY) Functions
- Window Functions
- Miscellaneous Functions
- Precision Math
- Set Operations
- List of Expressions for Pushdown
- TiDB Specific Functions
- Clustered Indexes
- Constraints
- Generated Columns
- SQL Mode
- Table Attributes
- Transactions
- Views
- Partitioning
- Temporary Tables
- Cached Tables
- Character Set and Collation
- Read Historical Data
- System Tables
mysql- INFORMATION_SCHEMA
- Overview
ANALYZE_STATUSCLIENT_ERRORS_SUMMARY_BY_HOSTCLIENT_ERRORS_SUMMARY_BY_USERCLIENT_ERRORS_SUMMARY_GLOBALCHARACTER_SETSCLUSTER_INFOCOLLATIONSCOLLATION_CHARACTER_SET_APPLICABILITYCOLUMNSDATA_LOCK_WAITSDDL_JOBSDEADLOCKSENGINESKEY_COLUMN_USAGEPARTITIONSPROCESSLISTREFERENTIAL_CONSTRAINTSSCHEMATASEQUENCESSESSION_VARIABLESSLOW_QUERYSTATISTICSTABLESTABLE_CONSTRAINTSTABLE_STORAGE_STATSTIDB_HOT_REGIONS_HISTORYTIDB_INDEXESTIDB_SERVERS_INFOTIDB_TRXTIFLASH_REPLICATIKV_REGION_PEERSTIKV_REGION_STATUSTIKV_STORE_STATUSUSER_PRIVILEGESVIEWS
- System Variables
- API Reference
- Storage Engines
- Dumpling
- Table Filter
- Troubleshoot Inconsistency Between Data and Indexes
- FAQs
- Release Notes
- Support
- Glossary
Migrate Data from MySQL-Compatible Databases
TiDB is highly compatible with MySQL. You can migrate data from any MySQL-compatible databases to TiDB smoothly, whether the data is from a self-hosted MySQL instance or RDS service provided by the public cloud.
This document describes how to use Dumpling to export data from MySQL-compatible databases and use TiDB Lightning logical import mode to import the data to TiDB Cloud.
If your upstream database is Amazon Aurora MySQL, instead of referring to this document, follow instructions in Migrate from Amazon Aurora MySQL to TiDB Cloud in Bulk.
Prerequisites
Before migrating data from MySQL-compatible databases into TiDB, ensure that the supported collations of TiDB Cloud can meet your requirements.
By default, TiDB Cloud supports the following CI collations:
- ascii_bin
- binary
- latin1_bin
- utf8_bin
- utf8_general_ci
- utf8_unicode_ci
- utf8mb4_bin
- utf8mb4_general_ci
- utf8mb4_unicode_ci
Step 1. Install TiUP
TiUP is a package manager in the TiDB ecosystem, which can help you run any TiDB cluster component with only a single line of command. In this document, TiUP is used to help you install and run Dumpling and TiDB Lightning.
Download and install TiUP:
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | shDeclare the global environment variable:
NoteAfter the installation, TiUP displays the absolute path of the corresponding
profilefile. In the following command, you need to modify.bash_profileto the path of yourprofilefile.source .bash_profile
Step 2. Export data from MySQL-compatible databases
You can use several ways to dump data from MySQL, such as using mysqldump or mydumper. It is recommended to use Dumpling for higher performance and compatibility with TiDB, which is also one of the open source tools created by PingCAP.
Install Dumpling:
tiup install dumplingExport your MySQL database using Dumpling.
To export your data to Amazon S3 cloud storage, see Export data to Amazon S3 cloud storage.
To export your data to local data files, use the following command:
tiup dumpling -h <mysql-host> -P 3306 -u <user> -F 64MiB -t 8 -o /path/to/export/dirIf you want to export only some specified databases, use
-Bto specify a comma-separated list of database names.The minimum permissions required are as follows:
SELECTRELOADLOCK TABLESREPLICATION CLIENT
Step 3. Import data to TiDB Cloud
Depending on the location and size of your source data, the importing methods are different.
If your source data is located in Amazon S3 cloud storage, take the following steps:
- Configure Amazon S3 access to allow TiDB cloud to access the source data in your Amazon S3 bucket. For more information, see configure Amazon S3 access.
- From the TiDB Cloud console, navigate to the TiDB Clusters page, and then click the name of your target cluster to go to its own overview page. In the upper-right corner, click Import Data, and then fill in the importing related information on the Data Import Task page.
If your source data is in local files, do one of the following:
- If the data is larger than 1 TB, it is recommended that you use Amazon S3 or GCS as a staging area to import or migrate data into TiDB Cloud. For more information, see Import or migrate from Amazon S3 or GCS to TiDB Cloud.
- If the data is less than 1 TB, you can use the logical import mode of TiDB Lightning according to the following steps in this document.
The following steps show how to import local data to TiDB Cloud using the logical import mode of TiDB Lightning.
Install TiDB Lightning:
tiup install tidb-lightningCreate a TiDB Lightning configuration file and configure the importing information.
Create the TiDB Lightning configuration file.
vim tidb-lighting.tomlConfigure the importing information.
[lightning] # The address and port to check TiDB Lightning metrics. status-addr = '127.0.0.1:8289' [tidb] # The target cluster information. Fill in one address of tidb-server. # For example: 172.16.128.1 host = "${host}" # The port number of the target cluster. For example: 4000 port = ${port number} # The target database username. For example: root user = "${user_name}" # The target database password. password = "${password}" [tikv-importer] # The TiDB backend to be used for data importing. backend = "tidb" [mydumper] # The data source directory, supporting local path and s3. # For example: `/data` for local path or `s3://bucket-name/data-path` for s3 data-source-dir = "${data_path}" # When Dumpling is used to export data, the corresponding table schemas are exported too by default. # If you want TiDB Lightning to automatically create table schemas in TiDB Cloud according to the exported schemas, set no-schema to false. no-schema = falseIf you want to configure TLS in the target TiDB cluster or do more configurations, see TiDB Lightning Configuration.
Import data into TiDB using TiDB Lightning:
nohup tiup tidb-lightning -config tidb-lightning.toml > nohup.out &After the importing task is started, you can view the importing progress in either of the following ways:
- To get the progress using command lines,
grepthe keywordprogressin logs, which is updated every 5 minutes by default. - To get more monitoring metrics using the TiDB monitoring framework, see TiDB Lightning Monitoring.
- To get the progress using command lines,