我下载了一个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
Stennie.. 16
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
--dbpath
如果要直接还原到数据文件而不是正在运行的MongoDB服务器实例,则只应包含该参数.
MongoDB手册中还有一些使用示例mongorestore
.
警告他人!我遇到了一个类似的问题,该问题是由于在TextEdit中保存命令然后进行复制和粘贴而引起的。TE必须一直在影响空格和破折号。
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
--dbpath
如果要直接还原到数据文件而不是正在运行的MongoDB服务器实例,则只应包含该参数.
MongoDB手册中还有一些使用示例mongorestore
.