使用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是版本號(hào),例如:( 2.4.9)
- 通過(guò)launchctl來(lái)啟動(dòng)和停止
mongod
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
- 你也可以使用命令
brew來(lái)啟動(dòng)、停止和查看服務(wù)的狀態(tài)。
brew services list | grep mongodb
brew services start mongodb
brew services stop mongodb
請(qǐng)注意:
默認(rèn)的plist文件指定的MongoDB配置文件是 /usr/local/etc/mongod.conf,
配置中dbpath為/usr/local/var/mongdb。