在做mongorestore时,“太多的位置选项”是什么意思?

时间:2013-12-21 02:12:44

标签: mongodb

我下载了一个mongodb转储。现在我正在尝试将文件从转储移动到我的mongodb位置。我正在使用mongorestore --dbpath [mongodb path] [dump path] cmd来执行此操作。但我在命令提示符中看到太多的位置选项错误。任何人都可以帮我解决这个问题。

这是命令行中的错误:

C:\Documents and Settings\>mongorestore -dbpath C:\Program Files\Mon
goDb\data\db C:\Documents and Settings\My Documents\localadventure
s\localadventures
ERROR: too many positional options

Import BSON files into MongoDB.

我今天再次尝试,并在我的cmd提示符中看到以下消息:

C:\>mongorestore --dbpath "C:\Program Files\MongoDb\data\db" "C:\Documents and S
ettings\seemanapallik\My Documents\localadventures\localadventures"
Mon Dec 23 09:05:01.515 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\adventure.bson
Mon Dec 23 09:05:01.515 [tools]         going into namespace [localadventures.ad
venture]
Mon Dec 23 09:05:01.531 [tools] warning: Restoring to localadventures.adventure
without dropping. Restored data will be inserted without raising errors; check y
our server log
1 objects found
Mon Dec 23 09:05:01.546 [tools]         Creating index: { key: { _id: 1 }, ns: "
localadventures.adventure", name: "_id_" }
Mon Dec 23 09:05:01.546 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\patch_version.bson
Mon Dec 23 09:05:01.546 [tools]         going into namespace [localadventures.pa
tch_version]
Mon Dec 23 09:05:01.546 [tools] warning: Restoring to localadventures.patch_vers
ion without dropping. Restored data will be inserted without raising errors; che
ck your server log
2 objects found
Mon Dec 23 09:05:01.562 [tools]         Creating index: { key: { _id: 1 }, ns: "
localadventures.patch_version", name: "_id_" }
Mon Dec 23 09:05:01.562 [tools] C:\Documents and Settings\seemanapallik\My Docum
ents\localadventures\localadventures\PaxHeader\adventure.bson
Mon Dec 23 09:05:01.562 [tools]         going into namespace [PaxHeader.adventur
e]
assertion: 16619 code FailedToParse: FailedToParse: Expecting '{': offset:0
Mon Dec 23 09:05:01.578 dbexit:
Mon Dec 23 09:05:01.578 [tools] shutdown: going to close listening sockets...
Mon Dec 23 09:05:01.578 [tools] shutdown: going to flush diaglog...
Mon Dec 23 09:05:01.578 [tools] shutdown: going to close sockets...
Mon Dec 23 09:05:01.578 [tools] shutdown: waiting for fs preallocator...
Mon Dec 23 09:05:01.578 [tools] shutdown: closing all files...
Mon Dec 23 09:05:01.609 [tools] closeAllFiles() finished
Mon Dec 23 09:05:01.609 [tools] shutdown: removing fs lock...
Mon Dec 23 09:05:01.609 dbexit: really exiting now

4 个答案:

答案 0 :(得分:15)

  

C:\ Documents and Settings> mongorestore -dbpath C:\ Program Files \ MongoDb \ data \ db C:\ Documents and Settings \ My Documents \ localadventures \ localadventures   错误:位置选项太多

如果您有包含空格的文件名或目录路径,则需要用双引号括起来。否则,mongorestore等命令行程序可能会合理地期望空格字符是新参数的开头而不是前一个值的延续。

提示:如果您使用 TAB 在Windows cmd.exe shell中自动填充文件名,则应自动添加正确的引号。

假设C:\Documents and Settings\My Documents\localadventures\包含您的mongodump文件,预期的mongorestore用法将为:

> mongorestore "C:\Documents and Settings\My Documents\localadventures\localadventures"

或者,您也可以先更改为转储目录以保存一些输入/引用。相对路径可以正常工作:

> cd "C:\Documents and Settings\My Documents\localadventures\"
> mongorestore localadventures

如果要直接还原到数据文件而还原到正在运行的MongoDB服务器实例,则应该只包含--dbpath参数。

MongoDB手册中还有一些examples of mongorestore usage

答案 1 :(得分:5)

预告他人!我遇到了类似的问题,这是由在TextEdit中保存命令然后只是复制和粘贴引起的。 TE必须影响空格和破折号。

答案 2 :(得分:1)

我的问题是没有带双连字符的设置标志。我没有像--d dbname那样设置数据库,而是执行了此操作-d dbname。糟糕!

答案 3 :(得分:0)

在我的情况下,我使用

mongorestore --db [dbname] [dumppath]

它有效。