1.使用Homebrew軟件包管理工具安裝
brew 又叫Homebrew,是Mac OSX上的軟件包管理工具,能在Mac中方便的安裝或者卸載軟件,類似于ubuntu系統(tǒng)下的
apt-get
如果你的系統(tǒng)中尚未安裝Homebrew,那就先裝好Homebrew:
在終端輸入如下命令即可
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"裝好brew后先對它進行更新
brew update接下來開始安裝mongodb
brew install mongodb安裝完成會提示如下結(jié)果:
To have launchd start mongodb now and restart at login:
brew services start mongodb
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
- 輸入
brew services start mongodb啟動mongodb,如果啟動成功,就會提示如下信息:
Successfully started
mongodb(label: homebrew.mxcl.mongodb)
- 最后,輸入
mongo進入mongodb,提示如下信息就表示一切順利~
MongoDB shell version: 3.2.11
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user