如何使用命令行将单个表导入mysql数据库 [英] how to import a single table in to mysql database using command line
问题描述
我使用命令行成功导入了一个数据库,但现在我的痛点是如何使用命令行将单个表及其数据导入现有数据库。
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.
推荐答案
Linux:
在命令行中
mysql -u username -p databasename < path/example.sql
将你的表放在example.sql中
put your table in example.sql
单个表的导入/导出:
-
导出表架构
Export table schema
mysqldump -u username -p databasename tableName > path/example.sql
这将创建一个名为 example.sql的文件
在提到的路径上并写入 create table
sql命令来创建表 tableName
。
This will create a file named example.sql
at the path mentioned and write the create table
sql command to create table tableName
.
将数据导入表格
mysql -u username -p databasename < path/example.sql
此命令需要一个包含为表
语句。所有 tableName
插入 insert
语句都将被执行并且数据将被加载。
This command needs an sql file containing data in form of insert
statements for table tableName
. All the insert
statements will be executed and the data will be loaded.
这篇关于如何使用命令行将单个表导入mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!