MongoDB:mongorestore:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17041337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MongoDB: mongorestore: command not found
提问by user2472438
I have started the M101 MongoDB online course. I am simply following this videoto the point at 1:45 minutes into the video.
我已经开始了 M101 MongoDB 在线课程。我只是在观看此视频的 1 分 45 分钟时到点。
The restoremongo
call returns mongorestore: command not found
. This should connect to the server(which I can connect to and is running on my machine).
该restoremongo
调用返回mongorestore: command not found
。这应该连接到服务器(我可以连接到并在我的机器上运行)。
This is where I am at; please see below. I have copied and pasted the server info beneath this.
Any solutions?
这就是我所在的地方;请看下面。我已将服务器信息复制并粘贴在此下方。
任何解决方案?
tar xvf hw1-1.957cdceb1c1e.tar
x dump/
x dump/m101/
x dump/m101/funnynumbers.bson
x dump/m101/funnynumbers.metadata.json
x dump/m101/hw1.bson
x dump/m101/hw1.metadata.json
Geralds-MacBook-Pro:Downloads geraldnolan$ mongorestore
-bash: mongorestore: command not found
Server:
服务器:
bsondump mongodump mongoimport mongorestore mongostat
mongo mongoexport mongooplog mongos mongotop
mongod mongofiles mongoperf mongosniff
Geralds-MacBook-Pro:bin geraldnolan$ ./mongod
./mongod --help for help and startup options
Tue Jun 11 10:30:06.413 [initandlisten] MongoDB starting : pid=15803 port=27017 dbpath=/data/db/ 64-bit host=Geralds-MacBook-Pro.local
Tue Jun 11 10:30:06.414 [initandlisten]
Tue Jun 11 10:30:06.414 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Tue Jun 11 10:30:06.414 [initandlisten] db version v2.4.4
Tue Jun 11 10:30:06.414 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Tue Jun 11 10:30:06.414 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Tue Jun 11 10:30:06.414 [initandlisten] allocator: system
Tue Jun 11 10:30:06.414 [initandlisten] options: {}
Tue Jun 11 10:30:06.415 [initandlisten] journal dir=/data/db/journal
Tue Jun 11 10:30:06.415 [initandlisten] recover : no journal files present, no recovery needed
Tue Jun 11 10:30:06.461 [websvr] admin web console waiting for connections on port 28017
Tue Jun 11 10:30:06.461 [initandlisten] waiting for connections on port 27017
回答by Black
if you installed mongo
using Macports, you need to also install mongo-tools
to get mongodump
, mongorestore
, etc
如果您安装mongo
使用MacPorts的,你还需要安装mongo-tools
拿到mongodump
,mongorestore
等
回答by eladHayun
if your'e on a mac, simply use brew to install mongo
如果你在 mac 上,只需使用 brew 安装 mongo
brew install mongo
回答by shank
It seems your PATH is not set for the mongodb.
看来你的 PATH 没有为 mongodb 设置。
Goto the directory where you "bin" directory is.
转到“bin”目录所在的目录。
In bin directory you will find the mongorestore command.
在 bin 目录中,您将找到 mongorestore 命令。
In the same terminal where your dump directory is, type:
在您的转储目录所在的同一终端中,键入:
export PATH = $PATH: "the complete path to your bin directory for Mongo"
After doing this execute > mongorestore dump
and it should run.
执行此操作后mongorestore dump
,它应该会运行。
See this https://discussions.apple.com/thread/1012390?start=0&tstart=0
看到这个https://discussions.apple.com/thread/1012390?start=0&tstart=0
回答by kelvincer
This works on Windows:
这适用于 Windows:
mongorestore "path/to/dump"
after
后
mongo
> use m101
> db.hw1.findOne()
回答by SHILPA AR
Below is what worked for me:
以下是对我有用的内容:
<complete path of mongorestore in your local mongo folder> -h <host:port> <complete path where the dump folder is present>
For example:
例如:
~/Documents/basicsoft/mongodb-osx-x86_64-3.0.5/bin/mongorestore -h 0.0.0.0:27017 ~/Downloads/dump
~/Documents/basicsoft/mongodb-osx-x86_64-3.0.5/bin/mongorestore -h 0.0.0.0:27017 ~/Downloads/dump
1. That is, when you give mongorestore, it may not be able to find the mongorestore command which is present in the bin folder of your local download of mongoDB(I am guessing that you are trying this in your local mongo instance). Hence you need to provide the complete path of the mongorestore present in bin folder
1. 也就是说,当你给 mongorestore 时,它可能无法找到你本地下载的 mongoDB 的 bin 文件夹中的 mongorestore 命令(我猜你是在你本地的 mongo 实例中尝试这个)。因此,您需要提供 bin 文件夹中存在的 mongorestore 的完整路径
- The second value is to specify that you are trying to perform this operation on your local server. Hence provide the local mongo server and port number after -h which indicates the host.
- 第二个值是指定您尝试在本地服务器上执行此操作。因此,在 -h 后提供本地 mongo 服务器和端口号,表示主机。
3. The third value should be the path to the folder which has the dump which should be restored to your mongodb.
3. 第三个值应该是具有转储的文件夹的路径,该转储应该恢复到您的 mongodb。
Make sure you have your mongoDB up and running before you try this.
在尝试此操作之前,请确保您的 mongoDB 已启动并正在运行。
回答by Radhika
I solved this problem like this on my Mac: Go to bin directory of Mongo installation and type following command: ./mongorestore --path of your homework dump folder--
我在我的 Mac 上解决了这个问题:转到 Mongo 安装的 bin 目录并键入以下命令:./mongorestore --path of your homework dump folder--
Note: make sure your mongod is running
注意:确保你的 mongod 正在运行
Verify: type in show dbs and you should see m101
验证:输入 show dbs,您应该会看到 m101