Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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


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:


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

sudo chown -Rv Your system name  /data/db

Then enter:


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


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,050 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,702 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.