mongodb数据库迁移

导出数据:

使用mongo自带命令来迁移数据,思路是先导出集合数据再导入到数据库中

导出命令:mongoexport

语法:mongoexport -d dbname -c collectionname -o filepath --type json/csv -f field

 

-d:数据库名

-c:集合名称

-o : 导出数据文件的路径

-type : 导出数据类型,默认json

导入数据:

导入命令:mongoimport

语法:mongoimport -d dbname -c collectionname --file filename --headerline --type json/csv -f field

-d:数据库名

-c:集合名称

--file : 选择导入的文件

-type : 文件类型,默认json

-f : 字段,type为csv是必须设置此项

猜你喜欢

转载自www.cnblogs.com/lmh001/p/9985710.html
今日推荐