Local MongoDB databases moved after Mac OSX upgrade to Catalina

So I had a few MongoDB databases running locally on my Mac but after upgrading to Catalina they all disappeared from the default path /data/db as the OSX Catalina upgrade introduced some new security settings.

After looking through folders and searching the web i struggled to find my databases but eventually found them under

/Users/Shared/Relocated Items/Security/data/db

If you look in the /Users/Shared/Relocated Items/Security folder you will see the official message from Apple to why the files have been moved


During the last macOS upgrade or file migration, some of your files couldn’t be moved to their new locations. This folder contains these files.

Files needing new locations
Some of your files had been in a location that is now incompatible with macOS security settings. These files were moved to the Security folder for your review.
If there are any files you want to keep, you can move them to a new location, as long as it is different from their location before the upgrade or migration.

Configuration files
These configuration files were modified or customized by you, by another user, or by an app. The modifications are incompatible with the recent macOS upgrade. The modified files are in the Configuration folder, organized in subfolders named for their original locations.
To restore any of the custom configurations, compare your modifications with the configuration changes made during the macOS upgrade and combine them when possible.

Copyright © 2019 Apple Inc. All rights reserved.


Solution

You will need to move the database files to another mongodb path location

Homebrew
If you installed MongoDB using Homebrew you will need to move the DB files to the new location under /usr/local/var/mongodb (unless you want it somewhere else)

Now you can launch mongod with command

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

Or you can add a bash, fish, zsh etc. alias for the command so you can launch mongodb easily using only mongod in terminal

Fish
nano ~/.config/fish/config.fish
Add following
alias mongod="mongod --dbpath /usr/local/var/mongodb"

Bash
nano ~/. bash_profile
Add following
alias mongod="mongod --dbpath /usr/local/var/mongodb"

Zsh
nano ~/. zshrc
alias mongod="mongod --dbpath /usr/local/var/mongodb"

Gudbrand Olimb

Hi! My name is Gudbrand and this is my attempt of a blog. Living & working in Oslo, Norway. Get in touch? Feel free to PM me.