我正在尝试恢复 mongo db 转储。在 PC 上运行 mongorestore 可以正常工作。但是当我在 linux 服务器(64 位 MongoDB)上运行它时,没有抛出错误,但没有导入数据。下面给出的是终端上的消息:
#mongorestore --drop dump
connected to: 127.0.0.1
Sun Nov 4 11:56:13 dump/m101/hw1.bson
Sun Nov 4 11:56:13 going into namespace [m101.hw1]
Sun Nov 4 11:56:13 dropping
1 objects found
Sun Nov 4 11:56:13 Creating index: { key: { _id: 1 }, ns: "m101.hw1", name: "_id_" }
Sun Nov 4 11:56:13 dump/m101/funnynumbers.bson
Sun Nov 4 11:56:13 going into namespace [m101.funnynumbers]
Sun Nov 4 11:56:13 dropping
100 objects found
Sun Nov 4 11:56:13 Creating index: { key: { _id: 1 }, ns: "m101.funnynumbers", name: "_id_" }
编辑:
这不是问题。问题不在于插入,而在于我的查询。我试图做 db.m101.funnynumbers.count()。正确的做法是 db.funnynumbers.count()。