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