2

After following official instructions here to install mongo-community, it cannot find the command to start mongo.

Steps I used to install mongo:

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

The installation was successful, but when I tried to start mongo with mongo. This error appears: zsh: command not found: mongo

Tried the solutions at Mongod: Command Not Found (OS X), none of them worked. Also, can't seem to find where mongo is located.

Thank in advance!

Kennard
  • 845
  • 2
  • 12
  • 32
  • That means either the installation didn't complete successfully or `/usr/local/bin` is not in your `$PATH` variable. See https://stackoverflow.com/questions/11530090/adding-a-new-entry-to-the-path-variable-in-zsh for adding the path to zsh. – kevinadi Oct 07 '19 at 22:05

2 Answers2

5

Add the path to "mongo" to your terminal shell:

export PATH="$PATH:/usr/local/Cellar/mongodb-community@3.6/3.6.14/bin"

(replace version number with your local version)

It cannot find the command since $PATH is not set correctly. After MongoDB moved from open source to community liscence on Oct 16, 2018, the installation path on Mac changed. It's installed in /usr/local/Cellar (reference: Location of the mongodb database on mac).

Thanks to @kevinadi for point out the issue.

Kennard
  • 845
  • 2
  • 12
  • 32
  • Just for information, this works with 3.4 version too. This is the path for 3.4 version: `/usr/local/Cellar/mongodb-community@3.4/3.4.23/bin` – Clauber Stipkovic Dec 18 '19 at 15:29
  • For me this here worked fine: export `PATH="$PATH:/usr/local/Cellar/mongodb-community/4.2.2/bin"` – Aleks Jan 20 '20 at 09:49
2

mongodb shell reference

In my case I couldn't find mongo command as 2022, so I used mongosh and it worked fine.

meBe
  • 154
  • 9