使用brew安装,不过brew不再更新,
通过
sudo chown -R $(whoami):admin /usr/local
这条语句终端有提醒的
xcode-select --install
需要安装这个xcode-select
brew install mongodb sed: .git/GITHUB_HEADERS: No such file or directory ==> Downloading https://homebrew.bintray.com/bottles-portable/portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz ######################################################################## 100.0% ==> Pouring portable-ruby-2.3.3.leopard_64.bottle.1.tar.gz ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core, homebrew/versions).
打算通过brew 安装mongodb,从而自动更新了ruby版本以及Homebrew的版本,然后再次执行
brew install mongodb
就可以了
==> Pouring mongodb-3.4.9.sierra.bottle.tar.gz
==> Caveats
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
//启动mongodb服务
brew services start mongodb
//浏览器
http://localhost:27017
显示
It looks like you are trying to access MongoDB over HTTP on the native driver port.证明安装成功了
//配置mongodb
mongod --config /usr/local/etc/mongod.conf
找不到mongodb安装在哪里,27017 的端口是能访问了,结果用
brew --cache
的命令查找了一下brew的安装路径
/Users/jamywong/Library/Caches/Homebrew
command + shitf + g
指定了一个新的端口27018,结果两个端口都可以访问,估计27017的端口是安装时的主文件端口
mongod --dbpath=/Users/jamywong/documents/nodejs/db --port=27018
重启系统后,发现monogdb数据库不能用了。
用了brew services start mongodb
成功地打了开了27017的数据库端口。
而27018的端口没能打开
试了一下
mongod --dbpath=/Users/jamywong/documents/nodejs/db --port=27018
就能打开了,27017与27018的端口正常运行
用terminal执行 brew list可以查看该brew下安装的内容。
来源:https://www.cnblogs.com/JamyWong/p/7686897.html