0

在 mongodump 之后,我做了 mongorestore 似乎工作正常

heathers-air:db heathercohen$ mongorestore -v -host localhost:27017
2015-02-06T11:22:40.027-0800 creating new connection to:localhost:27017
2015-02-06T11:22:40.028-0800 [ConnectBG] BackgroundJob starting: ConnectBG
2015-02-06T11:22:40.028-0800 connected to server localhost:27017 (127.0.0.1)
2015-02-06T11:22:40.028-0800 connected connection!
connected to: localhost:27017
2015-02-06T11:22:40.030-0800 dump/langs.bson
2015-02-06T11:22:40.030-0800    going into namespace [dump.langs]
Restoring to dump.langs without dropping. Restored data will be inserted without raising errors; check your server log
file dump/langs.bson empty, skipping
2015-02-06T11:22:40.030-0800    Creating index: { key: { _id: 1 }, name: "_id_", ns: "dump.langs" }
2015-02-06T11:22:40.031-0800 dump/tweets.bson
2015-02-06T11:22:40.031-0800    going into namespace [dump.tweets]
Restoring to dump.tweets without dropping. Restored data will be inserted without raising errors; check your server log
     file size: 4877899
30597 objects found
2015-02-06T11:22:41.883-0800    Creating index: { key: { _id: 1 }, name: "_id_", ns: "dump.tweets" }

但是,当我尝试访问数据时,它仍然是空的,并且它在还原之前的样子:

> show dbs
admin    (empty)
dump     0.078GB
local    0.078GB
tweets   (empty)
twitter  (empty)

它说它发现了 30597 个物体,它们去了哪里?

4

1 回答 1

0

他们进入转储数据库,然后进入集合dump.tweetsdump.langs. 文件包含在文件夹中的事实dump意味着mongorestore认为它们应该恢复到数据库中dump(它是从路径推断的)。详细的输出甚至明确指出数据正在被放入dump.langsdump.tweets专门放置。

如果您指定要还原到的数据库(使用-d)并还原特定文件,您将能够将文档还原到所需的数据库。或者,您可以简单地通过运行以下命令查看转储数据库:

use dump;
db.tweets.find();
db.langs.find();
于 2015-02-07T01:54:54.297 回答