MongoDB的安装有好多种安装方法,我选择了通过软件包管理Homebrew
1.Homebrew的安装非常简单,打开终端复制、粘贴以下命令,回车,即可安装成功
ruby -e"$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"
2.下面通过brew安装MongoDB
$ brew install mongodb
然后继续等待MongoDB下载完成
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mongodb-2.6
######################################################################## 100.0%
==> Pouring mongodb-2.6.5.mavericks.bottle.2.tar.gz
==> Caveats
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
==> Summary
/usr/local/Cellar/mongodb/2.6.5: 17 files, 331M
dus-MacBook-Pro:CountMeInServer dudaniel$
3.启动MongoDB
mongodb --dbpath=/Users/mrotaku/Desktop/nosql
--dbpath 指定文件的存放路径,默认端口号为27017
4.再启动一个终端
mongo localhost:27017
到这一步,mongodb安装完成
现在,你可以使用mongo命令了,去试试吧!