导出数据可以使用命令:
mongoexport -h dbhost -d dbname -c collectionName -o output

参数说明:
-h  数据库地址
-d 指明使用的库
-c 指明要导出的集合
-o 指明要导出的文件名

导出实例:

【mongoDB实战】mongoDB数据导入和导出

导出的是可以看到的数据,例如{"_id":"1112dfadfsafdsa","age":"23"}
【mongoDB实战】mongoDB数据导入和导出

2.导入:

导入数据可以使用命令:


mongoimport -h dbhost -d dbname -c collectionname output 


参数说明:
-h  数据库地址
-d 指明使用的库
-c 指明要导入的集合

导入实例:

将导出的11.txt的一条数据来讲解,将objectId进行修改,然后执行导入命令


【mongoDB实战】mongoDB数据导入和导出


【mongoDB实战】mongoDB数据导入和导出

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2021-09-22
  • 2022-12-23
  • 2021-10-14
  • 2021-06-28
  • 2021-06-16
  • 2022-12-23
猜你喜欢
  • 2021-11-12
  • 2022-12-23
  • 2021-04-27
  • 2022-12-23
  • 2021-08-13
  • 2021-12-25
  • 2021-06-10
相关资源
相似解决方案