简体   繁体   中英

Using mongodump: “mongodump: command not found”

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.

I installed mongo (I think) using the following commands:

curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.5.tgz > mongodb.tgz

tar -zxvf mongodb.tgz

brew tap mongodb/brew; brew install mongodb-community brew tap mongodb/brew; brew install mongodb-community will also install mongodump .

If you don't have the brew command, you really should consider install Homebrew

As of MongoDB 4.4 (released July 30, 2020), you may need to install mongodump separately because the MongoDB Database Tools (which comprises mongodump , mongorestore , and more) has become its own project .

I found this out because I upgraded to MongoDB 4.4 today and mongodump stopped working.

$ mongodump
zsh: command not found: mongodump

I'm on macOS and installed MongoDB via Homebrew. To get mongodump and friends back, I installed the MongoDB Database Tools via Homebrew:

brew tap mongodb/brew
brew install mongodb-database-tools

If you're on a different OS, this should help:

MongoDB Database Tools Installation

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:

./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, Homebrew to install MongoDB and have all the necessary binaries in PATH.

要使用 mongodump,必须从 os 包管理器安装mongo-tools库。

它可能不在您的路径中,它应该与您的“mongod”位于同一目录中,然后您可以使用以下命令运行它:

/path/to/bin/mongodump --host localhost:3002

It's in the official MongoDB docs now. For example, to install the 3.2 version:

brew tap mongodb/brew
brew install mongodb-community@3.2

Then follow the steps to update your PATH environment variable.

brew tap mongodb/brew
brew install mongodb-database-tools

您必须安装 mongo-tools 才能拥有 mongodump。

sudo apt-get install mongo-tools

安装mongodb客户端对我有用,对于ubuntu,可以通过以下命令完成:

sudo apt install mongodb-clients

For Windows Users

You can download the MongoDB Database Tools from here

And you can read the installation guide here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM