Mac下安装并启动MongoDB

##安装

直接请出包管理工具“Homebrew”大神

1
brew update
1
brew install mongodb

成功后提示

1
2
3
4
5
6
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod --config /usr/local/etc/mongod.conf

##Tips

  1. 若遇到遇到提示:

    1
    2
    2016-03-10T23:31:23.370+0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
    2016-03-10T23:31:23.371+0800 I CONTROL [initandlisten] dbexit: rc: 100

    为了方便学习,改变db目录至自己工作目录即可

    1
    sudo mongod --dbpath /Users/yang/Desktop/node/blog/db
  2. 若遇到出错提示:

    1
    2
    Server Crashing: Aborting after
    invariant() failture

    权限不够,加sudo即可。

0%