Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pingcap/tidb/llms.txt

Use this file to discover all available pages before exploring further.

TiDB supports several methods for importing and exporting data depending on dataset size and use case.

Export with Dumpling

Dumpling is the recommended tool for exporting large datasets. It exports data as SQL dump files or CSV.
# Export entire cluster as SQL
tiup dumpling \
  -u root -P 4000 -h 127.0.0.1 \
  --filetype sql \
  --output ./dump

# Export specific database as CSV
tiup dumpling \
  -u root -P 4000 -h 127.0.0.1 \
  --filter "mydb.*" \
  --filetype csv \
  --csv-separator "," \
  --output ./dump-csv

# Export with compression
tiup dumpling \
  -u root -P 4000 -h 127.0.0.1 \
  --compress gzip \
  --output ./dump-compressed

Dumpling options

FlagDescriptionDefault
--filetypeOutput format: sql or csvsql
--filterTable filter pattern (e.g. "db.*")all tables
--threadsParallel export threads4
--rowsSplit tables into chunks of N rows200000
--compressCompression: gzip, zstdnone
--outputOutput directory or S3/GCS path./export

Export with SELECT INTO OUTFILE

For small exports from within a SQL session:
SELECT * FROM orders
WHERE created_at >= '2024-01-01'
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
SELECT INTO OUTFILE writes to the TiDB server’s local filesystem. For large datasets, use Dumpling instead.

Build docs developers (and LLMs) love