我有很多的BSON文件在以下路徑:mongorestore語法錯誤
c:/mongodb/bin/dump/Sid
如果我運行命令:
> mongorestore --db Sid --drop dump/Sid
我收到以下錯誤:
Mon Mar 26 14:36:36 SyntaxError: missing ; before statement (shell):1
我的命令有什麼問題?
我有很多的BSON文件在以下路徑:mongorestore語法錯誤
c:/mongodb/bin/dump/Sid
如果我運行命令:
> mongorestore --db Sid --drop dump/Sid
我收到以下錯誤:
Mon Mar 26 14:36:36 SyntaxError: missing ; before statement (shell):1
我的命令有什麼問題?
從您的輸入看來,好像您正嘗試從JS shell內部運行mongorestore。
Mongorestore是一個獨立的應用程序,並直接從終端運行。
下將無法正常工作:
c:\mongodb-win32-x86_64-2012-03-20\bin>mongo.exe
MongoDB shell version: 2.1.1-pre-
connecting to: test
> mongorestore --db test --drop \dump\test
Mon Mar 26 11:29:13 SyntaxError: missing ; before statement (shell):1
>
如果從終端運行mongorestore直接,你應該是成功的:
c:\mongodb-win32-x86_64-2012-03-20\bin>mongorestore --db test --drop \dump\test
connected to: 127.0.0.1
... (truncated for brevity) ...
c:\mongodb-win32-x86_64-2012-03-20\bin>
上Mongodump/mongorestore的文檔可以在「導入找到導出工具「文檔: http://www.mongodb.org/display/DOCS/Import+Export+Tools
這對像我這樣的n00b非常有幫助。我無法弄清楚發生了什麼,因爲在文檔中不清楚mongorestore應該從終端運行,而不是從mongo shell運行。 – dwstein 2013-12-05 21:27:10
mongorestore不是通信和,它是MongoDB的bin目錄中的可執行文件。 下面是http://docs.mongodb.org/manual/reference/program/mongorestore/
The mongorestore program writes data from a binary database dump created by mongodump to a MongoDB instance. mongorestore can create a new database or add data to an existing database.
報價如果你已經有了一個的mongod實例運行 ,你已經指定了DBPATH爲
mongod --dbpath "..\mongodb\data"
您可以直接運行mongorestore命令。
mongorestore ..\data\dump
不能使用mongorestore命令是這樣的... 您必須通過CMD而不是蒙戈殼牌運行這個......看一看下面命令
>path\to\mongorestore.exe -d dbname -c collection_name path\to\same\collection.bson
這裏path\to\mongorestore.exe
是mongodb的bin文件夾裏面的mongorestore.exe
的路徑。 dbname
是databse的名稱。 collection_name
是collection.bson
的名稱。 path/to/same/collection.bson
是達到該集合的路徑。
現在來自mongo shell可以驗證數據庫是否被創建(如果它不存在,將使用集合創建具有相同名稱的數據庫)。
如果你想恢復外部數據庫,然後複製在
<pre>C:\database drive(Create a folder database and copy your database) ,then follow the steps
1)c:\> cd database
2)c:\database>dir
3)c:\database>"\Program Files\MongoDB\Server\3.0\bin\mongorestore.exe"
now open robomongo and check it will contain the restored dbs.. or check on command prompt show dbs</pre>
數據庫爲什麼要加上'--drop轉儲/ Sid'? – 2012-03-26 12:41:47
@Sergio在一篇文章中涉及了這個命令。我怎樣才能恢復該文件夾? – codious 2012-03-26 12:46:11
從備份複製。 – 2012-03-26 12:48:29