150

I'm relatively new to MongoDB and am trying to install MongoDB on my Mac with Homebrew, but I'm getting the following error:

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.

I ran brew update Then brew install mongodb

Paul Vu
  • 1,603
  • 2
  • 7
  • 6
  • 1
    That’s not really an error, you’re trying to install a package (formula) that doesn’t exist. Have you searched for a solution? The [official docs](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) have the correct command line. – bfontaine Sep 10 '19 at 08:11
  • 1
    Looks like `$ brew install mongodb-community@5.0` is not yet available via `brew`. Try `$ brew install mongodb-community@4.4 `. Also make sure to specify the correct version to `start ` and `stop` mongodb. – Pritam Patil Jul 16 '21 at 20:23

9 Answers9

441

Formula mongodb has been removed from homebrew-core. Check pr-43770 from homebrew-core

To our users: if you came here because mongodb stopped working for you, we have removed it from the Homebrew core formulas since it was migrated to a non open-source license.

Fortunately, the team of mongodb is maintaining a custom Homebrew tap. You can uninstall the old mongodb and reinstall the new one from the new tap.

# If you still have the old mongodb installed from homebrew-core
brew services stop mongodb
brew uninstall homebrew/core/mongodb

# Use the migrated distribution from custom tap
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community

Check mongodb/homebrew-brew for more info.

Simba
  • 23,537
  • 7
  • 64
  • 76
  • 1
    It only worked with `sudo brew services start mongodb-community`. Without sudo, my apps could never connect to a database because mongo defaulted to `/data/db` path regardless of its configuration. – Matthias Hagemann Apr 10 '20 at 10:53
  • 2
    @MattHagemann You may have messed things up. The default database location is `/usr/lobal/var/mongodb`, which could be confirmed by `brew cat mongodb-comunnity`. And don't use brew with sudo, which changes the owner of the package files and brings more trouble for you. I've explained once the bad of `sudo brew` [here](https://stackoverflow.com/a/58487534/5101148). – Simba Apr 10 '20 at 11:16
  • @Simba Thanks for the warning. I've been able to fix the ownerships and start the service without `sudo`. It turned out `WiredTiger.turtle` (and others) inside dbPath were still under root ownership and should have been under my ID. – Matthias Hagemann Apr 10 '20 at 23:11
  • 1
    `brew install mongodb-community` is changed to `brew install mongodb-community@4.4` –  Aug 26 '20 at 13:20
22

With regards to macOS Big Sur and Homebrew the mongodb documentation states: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

You should install MongoDB 4.4 Community Edition which supports macOS 10.13 or later, Therefor these steps will be helpful.

SOLUTION 1: If you have previously installed an older version of the formula, you may encounter a ChecksumMismatchError to fix that:

Remove the downloaded .tgz archive.

brew untap mongodb/brew && brew tap mongodb/brew

Retap the formula.

  brew install mongodb-community@4.4 

SOLUTION 2: If you haven't installed any version of the formula.

1, Install the Xcode command-line tools and the Homebrew from https://brew.sh/#install

xcode-select --install

2, Tap the MongoDB Homebrew Tap:

brew tap mongodb/brew

3, Verify installation prerequisites in the macOS Terminal:

brew tap | grep mongodb

4, install MongoDB

brew install mongodb-community@4.4

Note: The installation includes:

• The mongod server,

• The mongos sharded cluster query router,

• The mongo shell

refer to this screenshot:

enter image description here

Finally to run MongoDB (i.e. the mongod process) as a macOS service, issue the following:

brew services start mongodb-community@4.4

screenshot:

enter image description here

Ali Shirazee
  • 1,008
  • 10
  • 11
16

first install mongodb

brew tap mongodb/brew

Secondly install using this command. mangodb successfully installed

brew install mongodb-community@4.0 

You will get the output

==> CaveatsTo 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.2: 21 files, 274.5MB, built in 2 minutes 46 seconds
brew services start mongodb/brew/mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu
Sajeer Kunnoth
  • 169
  • 1
  • 5
8

Try this code in your terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

And then:

brew tap mongodb/brew  

Finally:

brew install mongodb-community@4.0
reza_khalafi
  • 6,230
  • 7
  • 56
  • 82
  • 2
    You may also need to add the `mongo` executable to your path or add it as an alias, e.g. `export PATH=$PATH:/usr/local/Cellar/mongodb-community@4.0/4.0.13/bin/` or `alias mongo=/usr/local/Cellar/mongodb-community@4.0/4.0.13/bin/mongo` – Everett Dec 11 '19 at 19:49
  • Then how to run the mongo deamon ? I mean the "mongod"-like command ?? – Hajar Elkoumikhi Jan 24 '20 at 15:54
1
~ % brew services run mongodb-community
/usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist: service already loaded

Error: Failure while executing
/bin/launchctl bootstrap gui/501 /usr/local/opt/mongodb-community/homebrew.mxcl.mongodb-community.plist
exited with 17.
Victor Lee
  • 2,467
  • 3
  • 19
  • 37
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 10 '21 at 22:09
1

Just go for

brew tap mongodb/brew
0

In MacOs Catalina doesn't work properly for me.

After the installation (https://zellwk.com/blog/install-mongodb/) i had to add permission to "/tmp/mongodb-27017.sock"

sudo chown -R `id -un` /tmp/mongodb-27017.sock

and the command "mongod" seems to ignore the config file (mongod.conf) in "/usr/local/etc" so i have to always launch it with the dbpath argument

mongod --dbpath /usr/local/var/mongodb

even if the same path is specified in the config file.

Also using "mongod" with configuration file doesn't work for me

mongod -f /usr/local/etc/mongod.conf

or

mongod --config /usr/local/etc/mongod.conf

I solved all these issues starting the mongodb via brew services. That worked well without issues and takes the parameters from the right configuration file.

brew services run mongodb-community
ArkoMo93
  • 110
  • 10
0

If you want mongo dump and some others, consider this one:

brew tap mongodb/brew
brew install mongodb-database-tools

This gave me:

mongodump     mongoexport   mongofiles    mongoimport   mongorestore  mongostat     mongotop

under

/usr/local/Cellar/mongodb-database-tools/100.7.0/bin/

And symlinked to

/usr/local/bin
phyatt
  • 18,472
  • 5
  • 61
  • 80
-1

Homebrew at times won’t get installed in max while the OS is updated , like recently Max OS Ventura - it’s not supported , we can quickly install Mongo DB without homebrew just by using some commands in terminal , checkout the details here : https://medium.com/@pratheushcmohan/install-mongodb-in-mac-without-using-home-brew-23b2556ff930