Mongodb Macos Catalina

  • 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.
  • MongoDB expects the Data/data/db folders to be in a location which Mac OS Catalina does not allow. As a consequence the folders must be placed elsewhere, on one of the disk volumes. But modifying the MongoDB settings to find the new data folders is not working properly. There are many supposed solutions for this in various places on the web but none of them have solved my issues.
14th Feb 2020

I had to reconfigure my Macbook after sending it for repairs. During the reconfiguration period, I noticed the instructions I linked to in “Setting up a local MongoDB connection” were outdated.

Uninstall mongodb mac catalina

Here’s an updated version on how to install MongoDB on a Mac.

Tap the MongoDB Homebrew Tap. Brew tap mongodb/brew; Install MongoDB Community Edition. Brew install mongodb-community; Run MongoDB Community Edition. Create a data folder. In macOS Catalina, you would need to create the data folder in System/Volumes/Data instead of /data/db. This is because the root folder is now read-only to help prevent the.

There are a few steps:

First, you install Homebrew. If you’re curious about what Homebrew is, read this article.

Second, find the MongoDB tap.

Third, install MongoDB.

MongoDB is now installed on your computer.

Preparations (Before MacOS Catalina)

Before you can use MongoDB, you need to create a /data/db folder on your computer to use MongoDB. You can create this folder with the following command:

You also need to give permissions to use it:

Now you can follow the rest of the article to set up your MongoDB connection.

Preparations (MacOS Catalina onwards)

Apple created a new Volume in Catalina for security purposes. If you’re on Catalina, you need to create the /data/db folder in System/Volumes/Data.

Use this command:

Then, use this command to give permissions:

Using MongoDB

In the past, I can run the mongod command to start MongoDB. This no longer works out for the box from MongoDB v4.2.3 onwards.

The best way to start MongoDB now is via brew services.

Starting MongoDB

Use this command:

MongoDB will start as a background service. Here’s what you’ll see:

You can use start instead of run. start will start MongoDB automatically when you login into your Macbook. I prefer run since I don’t want MongoDB to be running all the time.

Checking if MongoDB is running

Use this command:

Homebrew will list all running services. If MongoDB is running, mongodb-community will have a status set to started.

The Mongo Shell

If MongoDB is running, you should be able to access the Mongo shell with the mongo command.

Stopping MongoDB

Use this command:

Mongodb

Homebrew will stop MongoDB and let you know.

Aliases to make these easier

It’s a chore typing brew services run mongodb-community every time I want to start MongoDB.

I created some aliases to make things easier for me. Here are my aliases:

What’s next?

If you haven’t already, you should learn how to set up a local MongoDB connection.

If you enjoyed this article, please tell a friend about it! Share it on Twitter. If you spot a typo, I’d appreciate if you can correct it on GitHub. Thank you!

Question or issue on macOS:

I have already installed Mongodb on my mac but the process is currently not running.
How do I start the Mongodb service so that I can start using the commands?

How to solve this problem?

Solution no. 1:

Try the following steps in Terminal:

This will output the path to your mongod, but if it is not in your $PATH the command output will be empty. So you need to find your executable:

In the output of this command, you will see many lines, one of which will be like bin/mongod, e.g. /usr/local/mongodb/bin/mongod. In that case take the whole absolute path and do the following:

Then try again:

Mongodb

Solution no. 2:

If you used homebrew to install MongoDB on macOS you type the following in terminal. Should do the trick in most cases.

Solution no. 3:

To start the mongodb, you should only have to run the “mongod” command on the terminal.

Solution no. 4:

Just go into a folder where you want mongodb to store all the database files and run the command

mongod --dbpath=.

Solution no. 5:

Install and Run MongoDB with Homebrew

Open the Terminal app and type


brew update

After updating Homebrew


brew install [email protected]

After downloading Mongo, create the “db” directory. This is where the Mongo data files will live.
You can create the directory in the default location by running


sudo mkdir -p /data/db

Make sure that the /data/db directory has the right permissions by running


sudo chown -R id -un /data/db

Run the Mongo daemon, in one of your terminal windows run


brew services start mongodb-community

This should start the Mongo server.
Run the Mongo shell, with the Mongo daemon running in one terminal, type mongo in another terminal window. This will run the Mongo shell which is an application to access data in MongoDB.
To exit the Mongo shell run quit()
To stop the Mongo daemon hit ctrl-c

start service:


brew services start mongo

Solution no. 6:

Just do brew services start mongodb-community. Example:

Mongodb Mac Os Catalina Free

Of course, depends on your installation. This is the typical brew install.

Solution no. 7:

Mongodb Mac Os Catalina Update

For [email protected]

To start
run brew services start [email protected]

To end
run brew services stop [email protected]

source: Source

Solution no. 8:

Use this line it will fix the issue.

Execute this line in your terminal at the mongo bin path:

Macos Catalina Mongodb

<mongodb-install-directory> replace this with your path, for example:

Catalina

Solution no. 9:

Try with this following steps:

find your MongoDB path and MongoDB database path and run the below command

Hope this helps!