mongodb 使用 mongodump:“mongodump:未找到命令”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18123771/
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
Using mongodump: "mongodump: command not found"
提问by ediblecode
I'm trying to get a dump of my local database and it seems I should be using:
我正在尝试获取本地数据库的转储,看来我应该使用:
mongodump --host localhost:3002
However, the terminal then tells me:
但是,终端然后告诉我:
-bash: mongodump: command not found
Am I missing something? Or going about this the wrong way? I'm using it on Mac from the terminal.
我错过了什么吗?或者以错误的方式解决这个问题?我从终端在 Mac 上使用它。
I installed mongo (I think) using the following commands:
我使用以下命令安装了 mongo(我认为):
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.5.tgz > mongodb.tgz
tar -zxvf mongodb.tgz
回答by vinyll
回答by kciesielski
If you just extracted the .tgz file, the mongodump command is not available in your PATH. Go to your /bin/ subdirectory inside the directory where you have extracted mongodb.tgz, the mongodump binary should be there. Now you can execute:
如果您刚刚解压缩 .tgz 文件,则 mongodump 命令在您的PATH 中不可用。转到解压 mongodb.tgz 的目录中的 /bin/ 子目录,mongodump 二进制文件应该在那里。现在你可以执行:
./mongodump --host localhost:3002
It's much better though to install MongoDB with a package manager. Read this page: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/and use, for example, Homebrewto install MongoDB and have all the necessary binaries in PATH.
使用包管理器安装 MongoDB 会好得多。阅读此页面:http: //docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/并使用例如Homebrew安装 MongoDB 并在 PATH 中包含所有必要的二进制文件。
回答by Michael Horojanski
For using mongodump, mongo-tools
library has to be installed from os package manager.
要使用 mongodump,mongo-tools
必须从 os 包管理器安装库。
回答by Derick
It's probably just not in your path, it should be in the same directory as your "mongod", and you can then run it with:
它可能不在您的路径中,它应该与您的“mongod”位于同一目录中,然后您可以使用以下命令运行它:
/path/to/bin/mongodump --host localhost:3002
回答by AlexT
It's in the official MongoDB docsnow. For example, to install the 3.2 version:
它现在在官方的 MongoDB文档中。例如,要安装 3.2 版本:
brew tap mongodb/brew
brew install [email protected]
Then follow the steps to update your PATH
environment variable.
然后按照步骤更新您的PATH
环境变量。
回答by Prashanth Muthurajaiah
Installing mongodb clients worked for me, for ubuntu it can be done by the following command:
安装 mongodb 客户端对我有用,对于 ubuntu 可以通过以下命令完成:
sudo apt install mongodb-clients
回答by aPa
You have to install mongo-tools to have mongodump.
您必须安装 mongo-tools 才能拥有 mongodump。
sudo apt-get install mongo-tools