Sign In Try Free

Migrate from MySQL SQL Files Using TiDB Lightning

This document describes how to migrate data from MySQL SQL files to TiDB using TiDB Lightning. For details on how to generate MySQL SQL files, refer toDumpling.

The data migration process described in this document uses TiDB Lightning. The steps are as follows.

Step 1: Deploy TiDB Lightning

Before you start the migration,deploy TiDB Lightning.

Step 2: Configure data source of TiDB Lightning

This document takes the TiDB-backend as an example. Create thetidb-lightning.tomlconfiguration file and add the following major configurations in the file:

  1. Set thedata-source-dirunder[mydumper]to the path of the MySQL SQL file.

    [mydumper] # Data source directory data-source-dir = "/data/export"
  2. Add the configuration of the target TiDB cluster.

    [tidb] # The target cluster information. Fill in one address of tidb-server. host = "172.16.31.1" port = 4000 user = "root" password = ""
  3. Add the necessary parameter for the backend. This document uses the TiDB-backend mode. Here, "backend" can also be set to "local" or "importer" according to your actual application scenario. For details, refer toBackend Mode.

    [tikv-importer] backend = "tidb"
  4. Add necessary parameters for importing the TiDB cluster.

    [tidb] host = "{{tidb-host}}" port = {{tidb-port}} user = "{{tidb-user}}" password = "{{tidb-password}}"

For other configurations, seeTiDB Lightning Configuration.

Step 3: Run TiDB Lightning to import data

Run TiDB Lightning to start the import operation. If you start TiDB Lightning by usingnohupdirectly in the command line, the program might exit because of theSIGHUPsignal. Therefore, it is recommended to writenohupin a script. For example:

# !/bin/bash nohup ./tidb-lightning -config tidb-lightning.toml > nohup.out &

When the import operation is started, view the progress by the following two ways:

  • grepthe keywordprogressin logs, which is updated every 5 minutes by default.
  • Access the monitoring dashboard. SeeMonitor TiDB Lightningfor details.
Download PDF Request docs changes Ask questions on TiDB Forum
Was this page helpful?
Products
TiDB Cloud
TiDB
Pricing
Get Demo
©2023PingCAP. All Rights Reserved.