- The problem is related to the latest major macOS release, Catalina, and in this article, I’ll share my solution. Setting up MongoDB to run on Catalina is more time-consuming than it should be, but hopefully, this article will save you from some of the headaches I went through!
- To restart MongoDB running as a macOS service. Brew services restart mongodb-community@4.2 (or) brew services restart mongodb-community. To view if MongoDB is running as a macOS service or not. This gives you the list of macOS services running on your machine and you can view the status of MongoDB community from that list.
MacOS Catalina runs in a dedicated, read-only system volume. Since the directory /data/db is coded as MongoDB default, a workaround is to specify a different dbpath that is not located on the root directory. For example: mongod -dbpath /data/db This will place MongoDB’s data in your home directory. Before you can use MongoDB, you need to create a /data/db folder because MongoDB expects this directory (/data/db) on your machine to save the data. But Apple has already depreciated this directory on Catalina/BigSur machines and created a new volume on macOS Catalina for security purposes. Installing MongoDB on Mac Catalina using Homebrew This entry was posted in MongoDB and tagged Security troubleshooting on January 10, 2020 by Dan Wahlin I recently bought a new iMac and moved all of my files over using Time Machine.
If you are like me, running mongo servers on cloud IDE’s is just not the same as the customizations I have in my visual studio code. The need to test MongoDB servers locally sounds like an ideal option but I was running into issues trying to get the darn thing installed.
All the guides I found were over a year old and focused on OS-X or El Capitan. This one should work for Mac OS Catalina. This is an attempt to capture how to install MongoDB and run the Mongod (MongoDB Daemon) in some personal notes that may help someone in the future (at least myself). Originally, I tried following various installation guides that all failed to find the formula and ran into odd errors about directories that didn’t exist is read-only. My hope is that this will be a good reference for you.
If you are running Catalina, the old way of changing permissions for data/db
don’t work !
Steps to Install MongoDB locally
Create/open a project or clone a repo then head to the folder above that one.
First, you need brew installed. You can find instructions for that here: https://brew.sh/, then run:
Seriously, it’s that easy. No need to run chmod
like on other setups, you now have mongod and mongo running. You can test this by running:
You should see something like:
This means you did it!
In this tutorial I am going to talk about how you can install MongoDB on MacOS in an easy way. I have gone through many tutorials online, but I have been really upset with those tutorials. Most of the tutorials are outdated and old. So I decided to create this tutorial in which i can show you a better and easy way to setup MongoDB on MacOS.
Install MongoDB on MacOS using Homebrew
In order to install MongoDB on MacOs, I would suggest using Homebrew.
Please open up the MacOs command line tool and paste the following command to setup MongoDB on MacOS.
Once you entered the given above command, your MacOS terminal will start some process. Those processes are nothing but related to creating some folder in your local machine where all the Homebrew related settings are kept.
After finishing the installation process, check your Homebrew dependencies.
Hit the below commands to install MongoDB
After MongoDB successfully installed in your machine, then create a folder to store MongoDB data using given below command
Use the given below command to assign the proper permission to MongoDB data folder.
We’ve successfully installed the MongoDB on MacOS also assigned the proper permission. Now it’s time to run mongo daemon service. This service makes the connection and performs the task in the background. Hit the following command to run MongoDB.
Now your apps are all set to communicate with MongoDB. Mongo is correctly working in the background with the help of mongo daemon. You might also check which MongoDB version you are working on, just hit the below command in the terminal.
mongo --version output
Above command will tell you which MongoDB version is running in your local machine. Using the latest version has always been a good practice. It protects you from compatibility chaos with client-side app.
However, if you are using latest Mac version Catalina then the root folder is no longer writable.
Brew has an updated version of mongodb
to use a new path (which it creates itself), /usr/local/var/mongodb and following these instructions will fix the issue:
Mongodb Mac Os Catalina Update
Follow the link to install and update mongodb-community-edition