1. 同一个Mongodb实例下:
切换到源库
use db_source; # db_source = 需要拷贝数据的库
var test_copy = db_source.table.find(); # table = 要迁移的表
use db_target; # db_target = 拷贝的目标库
test_copy.forEach(function(d){db.coll_target.insert(d)}); # coll_target = 目标表

不同Mongodb实例之间
可以使用mongodump和mongorestore

备份:
mongodump -h host:port -d db_source -c collection_source
恢复
mongorestore -h host:port -d db_target -c collection_target dump/collection_source.bson

相关文章:

  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2021-11-08
  • 2022-12-23
  • 2022-01-24
  • 2021-11-12
  • 2022-01-18
相关资源
相似解决方案