mongodbmacosinstallation

command not found: mongo, after it's installed (OS X)


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!


Solution

  • 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.