How to export views using tiup dumpling

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tiup dumpling 如何导出试图

| username: love-cat

[TiDB Usage Environment] Production Environment
[TiDB Version] 5.2.2
[Reproduction Path]
When exporting TiDB views using the mysqldump command, some TiDB information is included. I want to use the tiup dumpling command to export the view and then import the view into MySQL.
Database: thc_1000_abc
View name: v_abcd

Export command:
tiup dumpling
–user root
–password aabbccdd
–port 4000
–tables-list thc_1000_abc.v_abcd
–database thc_1000_abc
–output thc_1000_abc/

[Encountered Problem: Problem Phenomenon and Impact]
After exporting, only the metadata and thc_1000_abc-schema-create.sql tables are present, but there is no view SQL. However, exporting non-view tables using this command works fine.
Is there an issue with the command I used?

| username: Billmay表妹 | Original post link

What attempt?

| username: love-cat | Original post link

Typo, it should be view.

| username: WalterWj | Original post link

-W, --no-views Do not dump views (default true) According to the new version of dumpling help, the default is to back up. You can try upgrading the dumpling version.

| username: Billmay表妹 | Original post link

The TiUP Dumpling tool can export table data from TiDB, but it currently does not support exporting views. If you need to export views, you can use the official MySQL mysqldump tool or the TiDB Lightning tool provided by TiDB.

If you use the mysqldump command to export TiDB views, it may include some TiDB-specific information, such as TiDB’s transaction IDs. If you need to import the views into MySQL, it is recommended to use the TiDB Lightning tool, which can export data from TiDB in a MySQL-compatible format, including view data. The specific steps are as follows:

  1. Install the TiDB Lightning tool:

    tiup install tidb-lightning
  2. Configure the TiDB Lightning tool:

    Example configuration file:

    # Path to the lightning log file
    log-file = "/path/to/lightning.log"
    # Path to the lightning progress file
    progress-file = "/path/to/lightning.progress"
    # Path to the lightning configuration file
    config-file = "/path/to/lightning.toml"
    # TiDB address
    host = ""
    # TiDB port number
    port = 4000
    # TiDB username
    user = "root"
    # TiDB password
    password = ""
    # Path to the mydumper export files
    data-source-dir = "/path/to/mydumper"
    # Number of mydumper threads
    threads = 16
    # Path to the myloader import files
    data-source-dir = "/path/to/myloader"
    # Number of myloader threads
    threads = 16

    The [tidb] section contains the TiDB connection information, the [mydumper] section contains the export data configuration, and the [myloader] section contains the import data configuration.

  3. Export TiDB data:

    Use the TiDB Lightning tool to export TiDB data, including view data:

    tiup tidb-lightning \
        --config /path/to/lightning.toml \
        --tidb-host \
        --tidb-port 4000 \
        --tidb-user root \
        --tidb-password "" \
        --backend local \
        --enable-checkpoint=false \
        --log-file /path/to/lightning.log \
        --progress-file /path/to/lightning.progress

    Here, --backend local indicates exporting data to a local file, --enable-checkpoint=false indicates not enabling checkpoints, and --log-file and --progress-file specify the paths to the log file and progress file, respectively.

  4. Import MySQL data:

    Import the exported data into MySQL, including view data:

    tiup tidb-lightning \
        --config /path/to/lightning.toml \
        --backend local \
        --mydumper-data-dir /path/to/mydumper \
        --myloader-data-dir /path/to/myloader \
        --log-file /path/to/lightning.log \
        --progress-file /path/to/lightning.progress

    Here, --backend local indicates importing data from a local file, and --mydumper-data-dir and --myloader-data-dir specify the paths to the export and import data, respectively.

| username: love-cat | Original post link

Thanks, I’ll give it a try.

| username: zhanggame1 | Original post link

You misunderstood, the default is not to back up, backing up is false

| username: love-cat | Original post link

Thank you very much, I will give it a try.

| username: WalterWj | Original post link

Oh, indeed haha

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.