天天看點

Mac OS安裝mongodb

1.使用

Homebrew

軟體包管理工具安裝

brew 又叫Homebrew,是Mac OSX上的軟體包管理工具,能在Mac中友善的安裝或者解除安裝軟體,類似于ubuntu系統下的

apt-get

  • 如果你的系統中尚未安裝Homebrew,那就先裝好Homebrew:

    在終端輸入如下指令即可

    ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

  • 裝好brew後先對它進行更新

    brew update

  • 接下來開始安裝mongodb

    brew install mongodb

  • 安裝完成會提示如下結果:
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