由于brew不再提供mongodb,因此需要安装mongodb-community

首先

因为需要MongoDB,所以打算安装。

$ brew install mongodb

Error: No available formula with the name "mongodb"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

由于被责备,我将留下安装方法。

解决方案

顺便提一下,如果在brew中搜索mongodb,

$ brew search mongodb

==> Casks
gcollazo-mongodb                                            mongodb-compass-community                                   mongodb-compass-readonly                                    nosqlbooster-for-mongodb
mongodb-compass                                             mongodb-compass-isolated-edition                            mongodbpreferencepane                                       homebrew/cask-versions/mongodb-compass-beta

已经没有了。

根据最新消息,好像MongoDB不再是开放源代码了,所以请执行以下操作。

$ brew tap mongodb/brew

==> Tapping mongodb/brew
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'...
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 13 (delta 4), reused 5 (delta 1), pack-reused 0
Unpacking objects: 100% (13/13), done.
Tapped 6 formulae (46 files, 60.1KB).

$ brew install mongodb-community

==> Installing mongodb-community from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.1.tgz
######################################################################## 100.0%
==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
  brew services start mongodb/brew/mongodb-community
Or, if you don\'t want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
?  /usr/local/Cellar/mongodb-community/4.2.1: 21 files, 273.5MB, built in 26 seconds

$ brew services start mongodb-community

==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)

通过这样做,您将能够使用它。

顺便说一下,我第一次使用了一个叫做brew tap的东西。

brew tap是将非官方存储库作为Homebrew的Formula添加到其中的工具,可以在brew环境下进行安装、卸载、更新等操作。当然,也可以轻松地添加自己发布的存储库。

(引述)据说,brew tap是指…