我有很多的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