做mongorestore时,“太多的位置选择"是什么意思? [英] What does “too many positional options” mean when doing a mongorestore?
问题描述
我下载了mongodb转储.现在,我正在尝试将文件从转储移至我的mongodb位置.我正在使用mongorestore --dbpath [mongodb路径] [转储路径] cmd来执行此操作.但是我在命令提示符中看到太多的位置选项错误.谁能帮我解决这个问题.
I downloaded a mongodb dump. Now i am trying to move files from the dump to my mongodb location. I'm using mongorestore --dbpath [mongodb path] [dump path] cmd to do this. But i am seeing the too many positional options error in the command prompt. Can anyone help me with this issue.
这是命令行中的错误:
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提示符下看到以下消息:
I tried again today and saw the following message in my cmd prompt:
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
推荐答案
C:\ Documents and Settings> mongorestore -dbpath C:\ Program Files \ MongoDb \ data \ db C:\ Documents and Settings \ My Documents \ localadventures \ localadventures 错误:位置选项过多
C:\Documents and Settings>mongorestore -dbpath C:\Program Files\MongoDb\data\db C:\Documents and Settings\My Documents\localadventures\localadventures ERROR: too many positional options
如果文件名或目录路径包含空格,则需要使用双引号将其引起来.否则,诸如mongorestore
之类的命令行程序可能会合理地期望空格字符是新参数的开头,而不是先前值的延续.
If you have filenames or directory paths containing spaces, these need to be enclosed in double quotes. Otherwise command line programs such as mongorestore
may reasonably expect that a space character is the start of a new parameter rather than a continuation of the previous value.
提示:如果在Windows cmd.exe
shell中使用 TAB 自动完成文件名,则应自动添加正确的引用.
Tip: If you use TAB to autocomplete filenames in the Windows cmd.exe
shell the correct quoting should be added automatically.
假设C:\Documents and Settings\My Documents\localadventures\
包含您的mongodump文件,则预期的mongorestore
用法为:
Assuming that C:\Documents and Settings\My Documents\localadventures\
contains your mongodump files, the expectedmongorestore
usage would be:
> mongorestore "C:\Documents and Settings\My Documents\localadventures\localadventures"
或者,您也可以先切换到转储目录,以节省一些键入/引用.相对路径就可以了:
Alternatively, you can also change to the dump directory first to save a bit of typing/quoting. A relative path works just fine:
> cd "C:\Documents and Settings\My Documents\localadventures\"
> mongorestore localadventures
仅在直接还原到数据文件而不是不还原到正在运行的MongoDB服务器实例中时,才应包括--dbpath
参数.
You should only include the --dbpath
parameter if you are restoring directly to data files and not into a running MongoDB server instance.
还有更多 MongoDB手册中mongorestore
用法的示例.
There are some more examples of mongorestore
usage in the MongoDB manual.
这篇关于做mongorestore时,“太多的位置选择"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!