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
?
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.
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.
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With