Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting read/write permissions on Mongodb folder

I just finished installing MongoDB on OSX and setup a directory structure with sudo mkdir -p /data/db.

When I attempt to run mongod from my user account it returns an error stating that my user account does not have read/write permission to /data/db.

How can I set the proper read/write permissions on my account for /data/db?

like image 323
Zoltan King Avatar asked Mar 11 '15 13:03

Zoltan King


People also ask

How do you change read permissions?

To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.

How do I view images in MongoDB?

In your application storage (mongo), you can store a URL/location to the image and then use that when retrieving the image in your javascript code. In addition, in your code I would recommend preloading images via javascript that preloads images before the user has scrolled to see them.


3 Answers

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
like image 180
davidcondrey Avatar answered Oct 27 '22 12:10

davidcondrey


sudo chmod 777 /data/db/ 

Should work on Mac. Before running this cmd, permissions look like

drwxr-xr-x  X User  wheel  Date /data/db

after running the cmd

drwxrwxrwx  X User  wheel  Date /data/db
like image 26
getSantsoh Avatar answered Oct 27 '22 13:10

getSantsoh


This is what worked for me. I am using a Mac, although you could try if you're using windows.

sudo chmod 777 /data/db
like image 6
Tim Anishere Avatar answered Oct 27 '22 13:10

Tim Anishere