mongodb mongorestore 错误:不知道如何处理转储文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21233290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mongorestore error: Don't know what to do with the dump file
提问by Prasanna Aarthi
I have mongo DB installed in the following path c:\mongodb\bin
. I have configured my environment variable PATH in advanced settings.I also have mongod running .When I run the following command mongorestore dumpfrom the following path c:\hw1-1\dump
(This contains the BSON files) I'm getting this error:
我在以下路径中安装了 mongo DB c:\mongodb\bin
。我已经在高级设置中配置了我的环境变量 PATH。我还运行了 mongod。当我从以下路径(包含 BSON 文件)运行以下命令mongorestore dump 时,c:\hw1-1\dump
我收到此错误:
Don't know what to do with the dump file
不知道如何处理转储文件
I have referred to this threadto check my path.
我已经提到这个线程来检查我的路径。
回答by clevertension
in mongodb 3.0 or above, we should specify the database name to restore
在mongodb 3.0及以上,我们应该指定要恢复的数据库名称
mongorestore -d [your_db_name] [your_dump_dir]
回答by Mzzl
You probably saw this error:
你可能看到了这个错误:
ERROR: don't know what to do with file [dump]
错误:不知道如何处理文件 [转储]
Which means in this case, that there is no file or directory called dump
in your current working directory. So, Try this first cd c:/hw1-1/
(or whatever the correct syntax is on Windows, I can't test it.) Alternatively you can specify the full path to the dump
directory:
这意味着在这种情况下,dump
当前工作目录中没有调用文件或目录。因此,请先尝试此操作cd c:/hw1-1/
(或 Windows 上的任何正确语法,我都无法测试。)或者,您可以指定dump
目录的完整路径:
mongorestore c:/hw1-1/dump
回答by punkrockpolly
If you're using mongoexport
to create the dump, be sure to use mongoimport
rather than mongorestore
to load it.
如果您正在使用mongoexport
创建转储,请确保使用mongoimport
而不是mongorestore
加载它。
回答by helmy
This error message "don't know what to do with file" can also occur if you have a BSON file that does not have a .bson file extension.
如果您的 BSON 文件没有 .bson 文件扩展名,也会出现此错误消息“不知道如何处理文件”。
Generally this isn't a problem since mongodump
generates the files with .bson extensions, but in my case I had a BSON file that was not generated by mongodump
and had a different file extension.
通常这不是问题,因为mongodump
生成带有 .bson 扩展名的文件,但在我的情况下,我有一个 BSON 文件,它不是由 .bson 生成的mongodump
并且具有不同的文件扩展名。
回答by Anton Wolkov
I'm on version 3.2 windows
and my mongorestore
seems to have a bug:
我在version 3.2 windows
,我mongorestore
似乎有一个错误:
If I specify /db:database_name
or /d database_name
I get the error:
如果我指定/db:database_name
或/d database_name
出现错误:
don't know what to do with subdirectory "dump\database_name", skipping...
Instead if I let it run on the whole dump directory it seems to work. The command I used is:
相反,如果我让它在整个转储目录上运行,它似乎可以工作。我使用的命令是:
mongorestore /host:remote_host dump
mongorestore /host:remote_host dump
My current directory structure is:
我当前的目录结构是:
.
..
dump
dump\database_name
回答by Donovan Thomson
I got this error when I had a collection matching the name of the one I was trying to restore present in Mongo ended up going into Mongo and deleting it using db.m101.drop();
当我有一个与我在 Mongo 中尝试恢复的集合的名称相匹配的集合最终进入 Mongo 并使用 db.m101.drop() 删除它时,我收到了这个错误;
回答by Roshan Khandelwal
It took me some time to figure out the options for mongorestore , after i had kept getting this error for some time .
在我不断收到此错误一段时间后,我花了一些时间来找出 mongorestore 的选项。
a) No running instances of mongod .
a) 没有正在运行的 mongod 实例。
b) mongorestore -v -host localhost:27017 --dbpath "Actual Path for the Mongo DB- set in config" "Location where the dump is"
b) mongorestore -v -host localhost:27017 --dbpath "Actual Path for the Mongo DB- set in config" "Location where the dump is"
Using dbpath , allows to run this command without any running version of mongod . And this resolved my error .
使用 dbpath ,允许在没有任何正在运行的 mongod 版本的情况下运行此命令。这解决了我的错误。