在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个物体,它们去了哪里?
答案 0 :(得分:0)
他们进入转储数据库,然后进入集合dump.tweets
和dump.langs
。文件包含在文件夹dump
中的事实意味着mongorestore
认为它们应该还原到数据库dump
(从路径推断出来)。详细输出甚至明确指出数据被特定地放入dump.langs
和dump.tweets
。
如果您指定要还原到的数据库(使用-d
)并还原特定文件,则可以将文档还原到所需的数据库。或者,您只需运行以下命令查看转储数据库:
use dump;
db.tweets.find();
db.langs.find();