使用Homebrew安裝MongoDB
brew install mongodb
配置自動(dòng)啟動(dòng)
- 鏈接plist文件
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
目錄/usr/local/opt/mongodb/
是一個(gè)鏈接,指向 /usr/local/Cellar/mongodb/x.y.z
x.y.z是版本號鳄逾,例如:( 2.4.9
)
- 通過launchctl來啟動(dòng)和停止
mongod
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
- 你也可以使用命令
brew
來啟動(dòng)、停止和查看服務(wù)的狀態(tài)破托。
brew services list | grep mongodb
brew services start mongodb
brew services stop mongodb
請注意:
默認(rèn)的plist文件指定的MongoDB配置文件是 /usr/local/etc/mongod.conf
厢绝,
配置中dbpath
為/usr/local/var/mongdb
。