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

How to Edit Permissions for data/db?

Hi,

I am getting the same issue as a few others where my /data/db directory is read-only.

When I go into finder -> get info to edit the permissions, it won't let me can't change anything :( is there a way to fix this? Or a way to change permissions using the terminal instead?

Thanks!

2 Answers

Balazs Peak
Balazs Peak
46,160 Points

Ensure that user account running mongod has the proper directory permissions. You can check which permissions are set like so:

ls -ld /data/db/ If they are set properly they should look something like this..

drwxr-xr-x X user wheel XXX Date Time /data/db/

If the permissions are set incorrectly you will likely see an error similar to this when attempting to run mongod

exception in initAndListen: XXXXX Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

To get the permissions set as they should be you can run the following command

sudo chmod 0755 /data/db && sudo chown $USER /data/db

Note: if you want to make it editable for all users on the machine, you can go like this instead:

sudo chmod 777 /data/db/

Cool that worked! I just had to change the owner. Thank you Balazs!!

Balazs Peak
Balazs Peak
46,160 Points

You're welcome! :) If you want to understand this more deeply, check out any Linux Basics course, and the "permissions for user/group/other" section in particular.