'zsh: command not found: mongo
I'm following the official instructions found here (on Mac OS Big Sur): https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
When attempting to run mongo
, I receive:
zsh: command not found: mongo
I then check if MongoDB is running by running:
brew services start [email protected]
I then receive:
Service [email protected] already started, use brew services restart [email protected] to restart
Because of this, I know MongoDB is running. What gives? I followed the official instructions from MongoDB's website.
Solution 1:[1]
For Apple M1 Processor:
If you install mongodb
through Homebrew
, follow the steps below:
Open up your
Terminal
Type
brew list
to check the formulae of the installedmongodb
==> Formulae
[email protected] mongodb-dxxx...
==> Casks
xxxxx
- In my case, it is
[email protected]
.
- In the terminal, type
brew list [email protected]
to get the directory of themongodb
installed in your machine.
/opt/homebrew/Cellar/[email protected]/4.4.13/bin/install_compass
/opt/homebrew/Cellar/[email protected]/4.4.13/bin/mongo
/opt/homebrew/Cellar/[email protected]/4.4.13/bin/mongod
/opt/homebrew/Cellar/[email protected]/4.4.13/bin/mongos
/opt/homebrew/Cellar/[email protected]/4.4.13/[email protected]
/opt/homebrew/Cellar/[email protected]/4.4.13/MPL-2
/opt/homebrew/Cellar/[email protected]/4.4.13/THIRD-PARTY-NOTICES
Copy the bin path of your mongodb:
/opt/homebrew/Cellar/[email protected]/4.4.13/bin
Open up your
.zshrc
file with any text-editorAdd this line to the file:
export PATH="/opt/homebrew/Cellar/[email protected]/4.4.13/bin:${PATH}"
- Try
mongo --version
in your terminal, if you see similar output like shown below, you are good to go.
MongoDB shell version v4.4.13
Build Info: {
"version": "4.4.13",
"gitVersion": "df25-----------b9246",
"modules": [],
"allocator": "system",
"environment": {
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
Solution 2:[2]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Solution 3:[3]
I solved my problem with this command running on terminal but only path i added is diffrent Steps-
- brew list [email protected]. (run this first)
- then copied - /opt/homebrew/Cellar/[email protected]/4.0.28/bin. this path
- and executed
echo 'export PATH="/opt/homebrew/Cellar/[email protected]/4.0.28/bin:$PATH"' >> ~/.zshrc source ~/.zshrc - then i have checked by openning .zshrc file is my path has set on not by executing - nano .zshrc command
and it's done
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Hanry |
Solution 2 | pzaenger |
Solution 3 | Rupali |