Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases Mongo Basics Getting Started With MongoDB Setting Up MongoDB

If you're having trouble installing Mongo on Mac.

Many of you may have ran in to this problem: You've installed mongo with HomeBrew and after entering

mongod

you've run into an error stating:

 IllegaleOperation: Attempting to create a lock file on a read-only directory: /data/db, terminating

The problem is not the directory, it's a Permissions problem and you'll need to change the ownership of that directory, first by entering:

whoami

so that you know what your system name is. Then enter:

sudo chown -Rv Your system name  /data/db

Then enter:

 mongod

everything should work fine.

control c to quit mongo and mongod

I also highly recommend you do one more thing. After you've shut out of mongo and mongod with

control c

clear the terminal with

clear

and enter:

brew services start mongo

This will allow you to skip having to enter "mongod" on one terminal and having to run "mongo" on another terminal every time you want to use it.

Routine Poutine
Routine Poutine
26,038 Points

Thank you. Your post helped me set the shell up, that was my main issue. However, I still cannot find MongDB on my hard drive -- it's not in the Downloads folder for some reason.

Do you know where MongoDB goes? It works, but I just don't know where it went.

2 Answers

Julianna Kahn
Julianna Kahn
20,701 Points

Yes, very helpful, thanks.

...and if you get an error saying that data files need to be fully upgraded before using version 4.0, you might want to check out this thread on Stackoverflow. You might need to use sudo on many of the commands.