How to install Mongodb on Mac

Install homebrew and run the following commands

#As of 2020, Homebrew does not allow to use shallow copy, you need to fetch from git using unshallow tag
sudo git -C "$(brew --repo homebrew/core)" fetch --unshallow

brew tap mongodb/brew

#Run this to install mongodb 4.2 or whatever is the latest version
brew install mongodb-community@4.2

#Run this to start Mongodb
brew services start mongodb-community

Run this check if mongodb service is running

ps aux | grep -v grep | grep mongod

#run this to connect to Mongodb
$mongo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: