Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 导入备份的数据时实现库名的修改
[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] tidb v6.1.0
[Reproduction Path] Operations performed that led to the issue
[Encountered Issue: When importing the exported data, modify the database name (data was exported using TiDB’s dumpling tool, and I want to import the data using the lightning tool with a new database name, essentially importing the data into a new database)]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
Change the name of the exported data file. The exported data file should be database_name.table_name
. Just change the database name to the new one.
Use the Lightning database and table conversion function.
Set the sharding merge rules to import table1 and table2 from my_db1, and table3 and table4 from my_db2, a total of 4 tables from 2 databases, into the table5 table in the target database my_db.
[[routes]]
schema-pattern = “my_db1”
table-pattern = “table[1-2]”
target-schema = “my_db”
For details, refer to: TiDB Lightning 配置参数 | PingCAP 文档中心
The Lightning configuration file can add a mapping:
[[routes]]
schema-pattern = “db”
target-schema = “test_db”