Mac使用brew安装mongodb

2019年10月18日 0 条评论 895 次阅读 0 人点赞

我们在mac系统中可以使用brew安装软件,但是brew现在安装mongodb默认已经不支持了,我们使用以下命令可以看到支持的mongodb列表

brew search mongo

返回以下信息

==> Formulae
mongo-c-driver                                 mongoose
mongo-orchestration

没有我们要安装的mongodb数据库服务,那么我们使用brew安装的话需要执行以下操作

安装mongodb必要操作


  • 安装mongodb数据源库
brew tap mongodb/brew
  • 检查是否存在mongodb源
> $ brew search mongo
==> Formulae
mongo-c-driver                                 mongodb/brew/mongodb-community-shell           mongodb/brew/mongodb-community@4.0
mongo-cxx-driver                               mongodb/brew/mongodb-community@3.2             mongoose
mongo-orchestration                            mongodb/brew/mongodb-community@3.4
mongodb/brew/mongodb-community                 mongodb/brew/mongodb-community@3.6
  • 安装mongodb
brew install mongodb-community

此时安装如果出现以下错误

Updating Homebrew...
==> Installing mongodb-community from mongodb/brew
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: An exception occurred within a child process:
  CompilerSelectionError: mongodb/brew/mongodb-community cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

系统提示没有gcc,我们可以使用以下命令解决

brew install gcc

此时可能会出现以下错误

> $ brew install gcc
Updating Homebrew...
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
==> Installing dependencies for gcc: gmp, isl, mpfr and libmpc
==> Installing gcc dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.2_2.catalina.bottle.1.tar.gz
==> Downloading from https://akamai.bintray.com/24/2409417943fceda33eac12a8229fbf7b990eee18ee341b543be575550a077bb0?__gda__=exp=1571379888~hm
######################################################################## 100.0%
==> Pouring gmp-6.1.2_2.catalina.bottle.1.tar.gz
🍺  /usr/local/Cellar/gmp/6.1.2_2: 18 files, 3MB
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.21.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/1f/1f42c08dd84a2f418c8446be2679f027d8b1250d337b5e3135c401eba578cbb7?__gda__=exp=1571379901~hm
######################################################################## 100.0%
==> Pouring isl-0.21.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/isl/0.21: 72 files, 4.3MB
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-4.0.2.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/14/140d29bfee0c8cf356fbb5391465f781df559e6076988de3ea8bcfd812f3c5bd?__gda__=exp=1571379931~hm
######################################################################## 100.0%
==> Pouring mpfr-4.0.2.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/mpfr/4.0.2: 28 files, 4.7MB
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.1.0.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.1.0.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libmpc/1.1.0: 12 files, 361.9KB
==> Installing gcc
Warning: Building gcc from source:
  The bottle needs the Xcode CLT to be installed.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: An exception occurred within a child process:
  CompilerSelectionError: gcc cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

看错误告诉我们是因为系统没有安装需要的CommandLineTools,这时我们需要以下命令更新xcode[安装可能会慢,根据当时的网络环境而定]

xcode-select --install

更新完成后在次安装gcc,然后安装mongodb即可.

qianmoQ

qianmoQ

这个人太懒什么东西都没留下

文章评论(0)