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 mongodb-community@4.4
I then receive:
Service mongodb-community@4.4 already started, use brew services restart mongodb-community@4.4 to restart
Because of this, I know MongoDB is running. What gives? I followed the official instructions from MongoDB's website.
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 installed mongodb
==> Formulae
mongodb-community@4.4 mongodb-dxxx...
==> Casks
xxxxx
mongodb-community@4.4
.brew list mongodb-community@4.4
to get the directory of the mongodb
installed in your machine./opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin/install_compass
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin/mongo
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin/mongod
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin/mongos
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/homebrew.mxcl.mongodb-community@4.4.plist
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/MPL-2
/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/THIRD-PARTY-NOTICES
Copy the bin path of your mongodb: /opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin
Open up your .zshrc
file with any text-editor
Add this line to the file:
export PATH="/opt/homebrew/Cellar/mongodb-community@4.4/4.4.13/bin:${PATH}"
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"
}
}
echo 'export PATH="/usr/local/opt/mongodb-community@4.4/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
I solved my problem with this command running on terminal but only path i added is diffrent Steps-
and it's done
Thanks
I did the above procedures and it still didn't work. But I restarted my terminal using $exec bash -l and it works!
I did the above procedures and it still didn't work. But use this, then it worked
brew install mongodb-community-shell
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.