转自:子龙的博客
安装配置MongoDB
使用Homebrew安装MongoDB
brew install mongodb
配置自动启动
链接plist文件
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
目录/usr/local/opt/mongodb/是一个链接,指向 /usr/local/Cellar/mongodb/x.y.z x.y.z是版本号,例如:( 2.4.9)
通过launchctl来启动和停止
mongodlaunchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plistlaunchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
你也可以使用命令
brew来启动、停止和查看服务的状态。brew services list | grep mongodbbrew services start mongodbbrew services stop mongodb
请注意:
默认的plist文件指定的MongoDB配置文件是 /usr/local/etc/mongod.conf,配置中dbpath为/usr/local/var/mongdb。
有关 launchctl 的更多信息,请查看: