How to specify the target database when importing with tidb-lightning?

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

Original topic: tidb-lightning导入的时候怎么指定导入数据库?

| username: lindoubled

TiDB version: v5.3.0

Using dumpling to export the database gamehub, and wanting to use tidb-lightning to import the database gamehub_benchmark, how should it be configured in lightning?

| username: caiyfc | Original post link

Two solutions:

  1. Change the file names. Dumpling exports files named as database_name.table_name. You can batch rename the database names to gamehub_benchmark.
  2. Use Lightning’s functionality and configure the parameters shown in the image below to replace the database name using regex.
| username: Running | Original post link

I encountered the same problem. There are many scenarios where importing and exporting require replacing the database name. It’s a bit difficult for DBAs to write regular expressions. I suggest providing some simpler methods.

| username: 啦啦啦啦啦 | Original post link

A few days ago, I encountered a similar problem. You can use a shell script to batch rename the files. You can refer to the following command:

for file in `ls | grep .sql`
do
 newfile=`echo $file | sed 's/old_db_name/new_db_name/g'`
 mv $file $newfile
done
| username: lindoubled | Original post link

I think the first option is still simple and clear :smiley:

| username: caiyfc | Original post link

“This also works. You can remove | sh to test it, and then execute it completely.”

| username: caiyfc | Original post link

Indeed, renaming is convenient, but one thing to note is that the gamehub_benchmark database must already exist. After renaming, Lightning will not automatically create the gamehub_benchmark database.

| username: TiDBer_pkQ5q1l0 | Original post link

Renaming is the most convenient.

| username: lindoubled | Original post link

Thank you, thank you.

| username: yulei7633 | Original post link

Just directly modify the database name.

| username: system | Original post link

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