26

I recently installed macOS Catalina 10.15 Beta 1. Now, when I try to launch my MongoDB application by running:

> mongod

I get the following error:

enter image description here

I have attempted to go to Security & Privacy and hit the Open Anyway button, but I get the same error.

Any thoughts on how to launch the application from the command line?

3
  • 1
    Have you tried opening it with CTRL pressed and select Open?
    – fsb
    Jun 21, 2019 at 21:40
  • 1
    Unable to open it with CTRL pressed because I have to open mongod server from the command line as there is no app in the applications.
    – zpeters
    Jun 24, 2019 at 20:21
  • As an alternative, I would like to suggest running MongoDB (and your application maybe) from Docker Desktop. Oct 10, 2019 at 7:24

17 Answers 17

7

Throw away your installation (saving any database files you need / export them) and then install the version from https://brew.sh

brew install mongodb
mongod --config /usr/local/etc/mongod.conf

You should be able to get v4.0.3 running without error and then compare if your distribution is compatible or needs adjustment if you can't use the mainline version for macOS.

Installing the program from the command line bypasses the gatekeeper checks and such and might be easier while the beta is new.

2
  • 1
    So... that produced another problem. Apparently my homebrew was hosed too. I threw ALL of it away. I mean ALL. I burned the whole thing down, erased the HD, reloaded macOS Mojave, upgraded to Catalina [10.15b2], reloaded homebrew and mongoDB. I guess I had a good deal of detritus all over my system that was preventing the original use. Good news is that I have a clean system to work from now. :)
    – zpeters
    Jun 24, 2019 at 20:25
  • Awesome! I’ve heard many brew survive the upgrade, but I’m glad a clean start worked and you didn’t have to assume it was just a mongo mess.
    – bmike
    Jun 24, 2019 at 22:56
23

Move your old /data/db folder into a non root folder and do the following:

brew uninstall mongodb
brew tap mongodb/brew

brew install mongodb-community

"brew install mongodb" won't work anymore as the mongodb is removed from the homebrew-core.

check https://github.com/mongodb/homebrew-brew for more info

ref: https://stackoverflow.com/a/57881349/10818622

1
  • 1
    So... that produced another problem. Apparently my homebrew was hosed too. I threw ALL of it away. I mean ALL. I burned the whole thing down, erased the HD, reloaded macOS Mojave, upgraded to Catalina [10.15b2], reloaded homebrew and mongoDB. I guess I had a good deal of detritus all over my system that was preventing the original use. Good news is that I have a clean system to work from now. :)
    – zpeters
    Oct 10, 2019 at 19:33
22

I updated to Catalina 10.15.2 from 10.14.X and the new security failed to recognize mongo as a trusted developer. Trying to run mongod in terminal triggered a system dialog (popup) refusing to run mongod with no option to override it.

System Preferences > Security & Privacy > General has a section at the bottom for app developer identity settings and also reports any recent related service denials. This is where you will find the coveted Allow Anyway button:

an alert about the recent refusal to trust that service and a button to allow it

Click that and run mongod in terminal again. You'll get a new security dialog with an Open button. Click it and mongo is back in the trust circle.

new alert with option to run the unrecognized mongo software

2
  • This appears to be the quickest and easiest approach - grab the tarball and tell macOS to allow it to run. Jun 26, 2021 at 15:20
  • Absolutely the best way, IMO
    – JESii
    Feb 19, 2022 at 15:34
11

For me it works without brew: Go to the folder, where the mongod binary is saved. Right click on it and then say: Open with - Terminal. It will ask you, if you really want to open. Click open. After that you can open it always without any further question dialogs.

6
  • that worked fine for me. Unfortunately Catalina just removed my /data/db folder ... WTF. Well, had a backup and copied it to my home folder now. Works as expected!
    – djnose
    Oct 16, 2019 at 8:18
  • @Lupurus Could you clarify where there binary is normally at when installing with homebrew?
    – kbpontius
    Jan 16, 2020 at 20:46
  • 1
    @kbpontius: I didn’t install via homebrew, I downloaded the binaries from mongodb.com
    – Lupurus
    Jan 17, 2020 at 21:46
  • 2
    Catalina moves it from /data/db to /Users/Shared/Relocated\ Items/Security/data/db - it does not remove it. Jan 22, 2020 at 4:59
  • NonExistentPath: Data directory /data/db not found. So you have to manually config the $PATH if using macOS 10.15.x, apple.com/macos/catalina/features
    – xgqfrms
    Jul 15, 2020 at 17:19
3

If mongo deamon can't create a db due to invalid file permission (in Catalina you cant create db folder in root as /data/db) or you missing mongod.conf (or mongo db can't read it).

brew uninstall mongodb
brew tap mongodb/brew
brew install mongodb-community

And start mongod manualy with

mongod --dbpath=/path/to/mongo/db
3

After you have installed it on Catalina, AND tried to run mongo in the terminal, you can go to Security and Privacy and in there, at the bottom you should see an option to allow "anyway". Then you will be able to run mongo and the other executables from the terminal.

3

I have tried all the answers above even after that I was getting the same error.

What really worked for me is after navigating to mongodb -> install on macOS: https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-os-x/#begin-using-mongodb

enter image description here

1
  • Nice answer. Worked for me. +1
    – Anish B.
    Sep 9, 2020 at 3:59
3

Update brew, install mongodb community version, create a new directory outside root since >=catalina apple wont let you put data in the root directory then update your mongo conf.

sudo mkdir -p /System/Volumes/Data/data/db
sudo chown -R `id -un` /System/Volumes/Data/data/db

brew uninstall mongodb
brew tap mongodb/brew

brew install mongodb-community

nano /usr/local/etc/mongod.conf

When the nano opens change the path change dbPath /System/Volumes/Data/data/db

Add some alias's if you want to get fancy.

alias mongod='brew services run mongodb-community'
alias mongod-start='brew services start mongodb-community' #will start MongoDB automatically when you login into your Macbook
alias mongod-status='brew services list'
alias mongod-stop='brew services stop mongodb-community'

Restart your terminal and then voilà you're in there like swim ware.

If you added the alias you can start mongo and check your dbs.

mongod-start
mongo
show dbs
2

Very late to the party here, but I've read that Catalina does not allow anything to be written on the root directory /

https://www.reddit.com/r/mongodb/comments/d7takd/macos_x_catalina_105_beta_and_mongo_a_warning/

Furthermore, your dbpath like others have mentioned, should also be placed in non-root directories as discussed here.

https://stackoverflow.com/questions/58283257/mongodb-doesnt-work-on-latest-mac-os10-15

2

From Apple: https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac, the salient point for services that you didn't open from the Finder being:

Note: You can also grant an exception for a blocked app by clicking the Open Anyway button in the General pane of Security & Privacy preferences. This button is available for about an hour after you try to open the app.

To open this pane on your Mac, choose Apple menu > System Preferences, click Security & Privacy, then click General.

2

this can be useful


# install homebrew (https://brew.sh/) and run the following commands
sudo chown -R $(whoami) $(brew --prefix)/*
brew tap mongodb/brew
brew install [email protected]

## --- aliases to set in your zshrc file

# open your zshrc file
open ~/.zshrc
# copy and paste shorcuts in the end of the file
alias mongod='brew services run mongodb-community'
alias mongod-start='brew services start mongodb-community' #will start MongoDB automatically when you login into your Macbook
alias mongod-status='brew services list'
alias mongod-stop='brew services stop mongodb-community'

# restart your terminal
# type mongod in your terminal for run service & mongod-stop for finish it
# test your mongodb connection with
mongo
show dbs

https://gist.github.com/sturmenta/cf19baa91b1d79d8ae2b305fb7e1f799

1
  • I've been going mad trying to get this to work - this has done the trick. From the gist you need "sudo chown -Rv <YOURUSER> /Users/$USER/mongo/db" to get it to write to root on Catalina $ id -un will get the user
    – Lauren
    Feb 5, 2020 at 23:31
1

I actually found my missing Mongo database. Apple had quietly moved it to Users/Shared/Relocated Items, along with my customized Apache conf file and a few other items. So nice of them to tell people all about this. This Apple install certainly sucked.

1

I also recently (4 days ago) updated to Catalina 10.15.2.

I also had the same error as reported by the OP.

My solution went as per the answer above

https://apple.stackexchange.com/a/377998/163049

but I had also used macports to install mongodb, and so it was installed with a view to using /data/db as the default. Hence I ran into the problem described here.

MongoDB can't find data directory after upgrading to Mac OS 10.15 (Catalina)

That is, my /data/db directory had been moved to /Users/Shared/Relocated\ Items/Security/data/db. So mongod still wouldn't start.

So I migrated my MacPorts installation to the Catalina version, by (mostly) following the instructions here:

Migrating MacPorts after a major operating system upgrade or from one computer to another

At the moment I am running

port upgrade outdated

The theory is that mongod will be reinstalled in such a way as to work properly on Catalina. That way I avoid the misery of trying to work out how to write a valid YAML file. I hate YAML.

0

/ SOLVED /

I got this solved just by running mongo in the command line with super user permissions, so prepending sudo (Super User DO).

sudo mongo
1
  • This is a bad solution -- once beginners learn of sudo they know just enough code to be dangerous. Look for solutions that don't use sudo and only use it when absolutely necessary, not to circumvent your own security measures to run a common /networking/ application. askubuntu.com/a/16179 - elementaryos.stackexchange.com/a/450
    – Cam
    Sep 28, 2020 at 19:09
0

This page has the BEST instruction on how to install and run on Catalina.

https://zellwk.com/blog/install-mongodb/

0

You could just remove the quarantine flag from your MongoDB executable files:

xattr -r -d com.apple.quarantine $(dirname $(which mongod))
0

I was facing the same problem I had to do two things

  1. allowing mongod and mongo to execute by going through System Preferences > Security & Privacy > General and clicking Allow Anyway

  2. changing the path to db as mongod still failed to start after the allow. the new path is /Users/Shared/Previously Relocated Items/Security/data/db

mongod --dbpath=/Users/Shared/Previously\ Relocated\ Items/Security/data/db

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .