How to import a single table in to mysql database using command line

前端 未结 18 1844
你的背包
你的背包 2020-12-22 15:25

I had successfully imported a database using command line, but now my pain area is how to import a single table with its data to the existing database using command line.

18条回答
  •  有刺的猬
    2020-12-22 16:02

    Using a temporary database could be a solution depending on the size of the database.

    mysql -u [username] -p -e "create database tempdb"
    mysql -u [username] -p tempdb < db.sql
    mysqldump -u [username] -p tempdb _table_to_import_ > table_to_import.sql
    mysql -u [username] -p maindb < table_to_import.sql
    

提交回复
热议问题