Mongodb Install Mac Catalina

I recently bought a new iMac and moved all of my files over using Time Machine. The migration went really well overall and within a few hours I had my development machine up and running. After starting an application I’m building I quickly realized that I couldn’t get MongoDB to start. Running the following command resulted in an error about the data/db directory being read-only:

  1. Mongodb Install Mac Catalina Download
  2. Mongodb Install Macos Catalina
  3. Mongodb Install Mac Catalina Update
  4. Mongodb Install Mac Catalina Os
  5. Install Mongodb Mac Catalina

I tried every chmod and chown command known to man and woman kind, tried manually changing security in Finder, compared security to my other iMac (they were the same), and tried a bunch of other things as well. But, try as I might I still saw the read-only folder error when trying to start the server….very frustrating. I found a lot of posts with the same issue but they all solved it by changing security on the folder. That wasn’t the problem on my machine.

These are the most probable errors and how to solve and setup MongoDB on macOS Catalina. Please do have a look into my YouTube channel: Code Studio Sai Ankit that discusses everything related to coding from Computer Science Concepts, Competitive Coding tutorials, Codeforces Editorials, Development Projects. This article explains how to quickly set up MongoDB on macOS Catalina. Install homebrew The Missing Package Manager for macOS! Install MongoDB community version. While writing this article the.

  1. How to install MongoDB on Mac OS Catalina (locally) 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.
  2. I am using MacOS Catalina and installed XAMPP on it. When I am trying to install PHP MongoDB driver using following command, it gives me errors mentioned below. Sudo pecl install mongodb I am getting.

After doing more research I found out that Catalina added a new volume to the hard drive and creates a special folder where the MongoDB files need to go. The new folder is:

The MongoDB files can then go at:

I ran the following commands to install the latest version of MongoDB using Homebrew (see https://github.com/mongodb/homebrew-brew for more details):

I then went into the MongoDB config file at /usr/local/etc/mongod.conf. Note that it’s possible yours may be located in a different location based on how you installed MongoDB. I changed the dbPath value to the following and copied my existing DB files into the folder:

Finally, I made sure my account had the proper access to the folder by running chown (something I had tried many times earlier but on a folder outside of /System/Volumes/Data):

After that I was able to start MongoDB and everything was back to normal. Hopefully this saves someone a few hours – I wasted way too much time on the issue. 🙂



Mongodb Install Mac Catalina

Question or issue on macOS:

I recently installed mongodb-2.6.0 with Homebrew.
After successfully installed, I tried to connect using the mongo command. I am receiving the following errors which do not allow me to connect:

How to solve this problem?

Solution no. 1:

It can happen when the mongodb service is not running on the mac. To start it, I tried

Mac

and it worked.

Mongodb Install Mac Catalina Download

Edit: According to the discussion on this PR on homebrew: https://github.com/Homebrew/homebrew/issues/30628

Mongodb Install Mac Catalina

brew services is deprecated, I looked around on SO and found these answers now answer the question: What is the correct way to start a mongod service on linux / OS X?

Solution no. 2:

I encountered the exact same issue and here is a clear step by step process to avoid this error.

Step 1 – Installation ( Don’t follow this step if you have already installed MongoDB ):

Step 2 – Run Mongo Daemon:

Step 3 – Run Mongo Shell Interface:

In this sequence, I was able to run the mongo command without any error. I have also detailed the error trace and its solution on this blog.

Solution no. 3:

To solve your issue you need to follow the instructions which are then given to you by brew after you use “brew install mongodb”.

To have launchd start mongodb at login:

Then to load mongodb now:

Or, if you don’t want/need launchctl, you can just run:

You may be able to just run that last command, but it didn’t work for me and I needed to run the second command. To save me in the future. I just ran the first command too. Hope that helps!

EDIT Hrishi’s method of using brew services mongodb start worked good for me. I think they should include this in the mongo docs.

Solution no. 4:

In another tab, you can start the mongo shell with


mongod

Then return to the previous tab and try again. If you’re having trouble setting up your mongoshell, check out this link on the mongo shell: http://docs.mongodb.org/manual/tutorial/manage-mongodb-processes/
or this link on installing mongodb:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

Solution no. 5:

I was having the same issue when calling mongod from the command line.

I resolved this by calling instead sudo mongod.

Solution no. 6:

I had the same error but a different root cause. Thought I’d post the solution here in case anyone else runs into the problem. I got this error after my Mac improperly shut down while I was running mongorestore -d foo dump/foo/.

tl;dr: I fixed the problem by removing the damaged foo.ns file along with foo.0, foo.1,… from my data folder /usr/local/var/mongodb/. Then I restarted the mongo server with brew services restart mongodb and I was back to normal.

Details: I kept getting the error even after trying to start or restart the mongodb service via brew or launchctl. Eventually I ran

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

and saw that the service was not actually starting, and the start sequence included the following error:

[initandlisten] bad .ns file: /usr/local/var/mongodb/foo.ns
[initandlisten] User Assertion: 10079:bad .ns file length, cannot open database

I got rid of the bad .ns file and the rest of the data files, and the next time I started the service I was good to go.

Solution no. 7:

for me on osx, I had to kill old running instance, then restarting worked.

Solution no. 8:

For anyone who is here looking for the answer for this after your mac has updated to OS Catalina

run

find more info here: https://medium.com/@semmons245/arghhhh-thanks-to-the-catalina-os-update-this-now-needs-changing-987f416ebcbe

Solution no. 9:

I got this error after I upgraded to mongo 3.6 with homebrew.

The log /usr/local/var/log/mongodb/mongo.log contained the message shutting down with code:62. This error code means that the existing database is too old to run with the current version of mongo.

I found 2 solutions in another SO question:

  • Delete your database folder (/usr/local/var/mongodb)
  • Or follow the upgrade procedure

I chose to upgrade. In my case, that meant I had to downgrade to 3.4, run a command in the mongo console, then upgrade again. Mongo requires you to upgrade one major version at a time, so depending on how far back you were, there could be additional steps. The docs will guide you.

The brew switch * and brew services restart commands made swapping between versions relatively painless.

Mongodb Install Macos Catalina

Solution no. 10:

If you have already installed MongoDB then first try to run mongod as a sudo user, I was facing the issue because of not running mongod as a superuser.

I have pasted the o/p for both the commands(mongod and sudo mongod) at very bottom, you can check that too but

First try this

not this

I had installed MongoDB on my MAC OS X Sierra 10.12.6 by by running the following command in sequence.

then created a directory to which mongod process will write the data, this is optional as mongod process takes it by default, see this useful guide at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

Mongodb Install Mac Catalina Update

Finally started mongod process as follows

Oputput of mongod (failed) and sudo mongod (succeeded) commands on my terminal.

Then I opened new terminal to start querying the MongoDB, it worked.

Mongodb Install Mac Catalina Os

That’s it.

Install Mongodb Mac Catalina

Hope this helps!