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