brew tap mongodb/brew # brew tap 三方源
brew search mongo # 确认是否已安装, 查找mongo合适的版本
2. 安装并配置
2.1. 安装
liuxianqiang-mac:/ liuxianqiang$ brew install mongodb-community@4.2
==> Installing mongodb-community@4.2 from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.9.tgz
######################################################################## 100.0%==> Caveats
mongodb-community@4.2 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mongodb-community@4.2 first in your PATH run:
echo'export PATH="/usr/local/opt/mongodb-community@4.2/bin:$PATH"'>> /Users/liuxianqiang/.bash_profile
To have launchd start mongodb/brew/mongodb-community@4.2 now and restart at login:
brew services start mongodb/brew/mongodb-community@4.2
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺 /usr/local/Cellar/mongodb-community@4.2/4.2.9: 21 files, 306.4MB, built in 6 seconds