QiitaでMacにMongoDBをインストールする記事を探すと、古く実行できない記事が多いので、2019年12月現在インストールできる方法を書いておこうと思います。
普通にHomebrewではインストールできない?
MongoDB を MacOSX にインストールしようと思い、以下のコマンドを実しました。
bash
$ brew install mongodb
しかし、以下のようなエラーが出てきました。
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.
MongoDBが見つからないと出てきます。
どうやら Homebrew の Core Repository からは、MongoDBは削除されたようです。
(Qiitaには、この方法で入れる記事がたくさんありますが...)
解決方法
MongoDB公式で、 brew tap
を使ってMongoDBのリポジトリを参照して入れることが推奨されています。
bash
# MongoDBのリポジトリを参照
$ brew services start mongodb-community
# MongoDBをインストール
$ brew install mongodb-community
# MongoDBを実行
$ brew services start mongodb-community
# MongoDBのバージョンを確認
$ mongo -version
MongoDB shell version v4.2.1
...
以上でインストールと確認ができると思います。
詳細は、公式リファレンスをご確認ください。
Mongo DB Official Reference "Install MongoDB Community Edition on macOS"
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/