Answer a question

I have tried the following steps to install and setup mongodb in my mac from here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ but I got the following error when running the final "mongo" command in my terminal:

Error Message - Zsh: Command Not found : mongo

This error msg occurred after trying to install mongodb 4.2 using brew

sudo chown -R $(whoami) $(brew --prefix)/*

then

brew tap mongodb/brew

then

brew install mongodb-community@4.2

and

brew services start mongodb-community@4.2

or

mongod --config /usr/local/etc/mongod.conf

then

ps aux | grep -v grep | grep mongod

and

mongo

running brew services start mongodb-community@4.2 returns:

Successfully started `mongodb-community@4.2` (label: homebrew.mxcl.mongodb-community@4.2)

running ps aux | grep -v grep | grep mongod returns:

9081   0.2  0.5  5528024  41856   ??  S     3:01pm   0:01.48 /usr/local/opt/mongodb-community@4.2/bin/mongod --config /usr/local/etc/mongod.conf

7613   0.0  0.1  4298832   5600 s000  T     2:47pm   0:00.08 vim /usr/local/etc/mongod.conf

running mongod --config /usr/local/etc/mongod.conf returns:

zsh: command not found: mongod

There are also no mongo files in my /usr/local/bin directory after using these commands

I created a data/db folder in my /usr/local/bin directory using the following commands:

sudo mkdir -p  /usr/local/bin/data/db   
sudo chown -R `id -un`  /usr/local/bin/data/db      

Running "brew update" returns:

brew update                                                                                                                                                    
Updated 1 tap (homebrew/cask).
==> Updated Casks
brave-browser

Answers

Solved it by manually installing the mongodb community files and db tools using the website instead. Then copying them into /usr/local/bin. Then ignoring the app permissions whenever calling mongo or related commands in the terminal through System Preferences > Security & Privacy > General.

After googling I found out that mongoimport and the other features have to be installed separately: https://www.mongodb.com/try/download/database-tools

Followed by copying those bin files after extracting them into the same /usr/local/bin directory

Not sure why its' not working through homebrew though

Logo

MongoDB社区为您提供最前沿的新闻资讯和知识内容

更多推荐