Thet Hmuu
Caleb's Blog

Follow

Caleb's Blog

Follow
How to fix "zsh: command not found: mongo" in MongoDB v6

How to fix "zsh: command not found: mongo" in MongoDB v6

Thet Hmuu's photo
Thet Hmuu
·Dec 11, 2022·

1 min read

If you've installed mongodb community edition via Homebrew on your mac, and it shows that error in the title, you can fix performing the following steps.

Note*: mongo is deprecated and mongosh is the new way to use mongodb shell. See in official docs.

  1. Open your Terminal

  2. Type brew list to check the installed mongodb. Find along the line mongodb-community. Your case maybe mongodb-community@6.0

  1. Type again brew list mongodb-community to get the directory installed on your machine.

  2. Copy the bin path of mongodb until the 'bin'

    for my case - /opt/homebrew/Cellar/mongodb-community/6.0.1/bin

  3. Open .zshrc with nano or other text editor: nano .zshrc

  4. Add this in the file (combining with ${PATH} in the above path):

    export PATH="/opt/homebrew/Cellar/mongodb-community/6.0.1/bin:${PATH}"

  5. Save and exit.

  6. Run mongosh and it should work now. ✨

 
Share this