用 Homebrew 安装MongoDB:
首先安装 Homebrew:
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
如果已经安装过 Homebrew 升级到最新版本:
1 | brew update |
安装 mongodb:
1 | brew install mongodb |
安装成功后更具brew提示启动mongodb:
后台启动 mongodb:
1 | brew services start mongodb |
后台停止 mongodb:
1 | brew services start mongodb |
当前控制台运行(关闭控制台窗口后mongodb会退出)
1 | mongod --config /usr/local/etc/mongod.conf |