I just downloaded mongodb onto my brandy new MacBookAir with OS X 10.9.5 by doing brew install mongodb
.
I tried to run mongod
from Terminal and it said "no /data/db" so I created it with sudo mkdir /data
and sudo mkdir /data/db
.
Running mongod now I get "Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied" but I can run it perfectly fine with sudo mongod
.
How can I make it so that I don't have to run mongod with sudo, but instead just as simply mongod
?
(I had it like that on my last computer but do not remember what I did at all, and that computer was all messed up anyway.)
This worked for me:
sudo chmod -R 777 /data/db
then
sudo chown -R `id -u` /data/db
The -R
makes the command recursive; I had previously tried both sudo chmod 777 /data/db
and sudo chown `id -u` /data/db
as instructed on other StackOverflow answers but they failed.
(PS I'm sorry I know this is a very old question but I found it while trying to look for an answer to my problem; and since I managed to solve it I thought I'd put this here for anyone in the future. Also I'm not sure which of those two commands made the difference, but it worked.)
Simple Start it with
mongod --dbpath ~/.mongodb/data --logpath ~/.mongodb/mongod.log --fork
after you did an
mkdir ~/.mongodb
The problem is that the default dbpath /data/mongodb
was created for root.
Another option would be to do a
chown <your username here> -R /data/mongodb
And run mongod with the default paths.
As an alternative to running MongoDB directly under OSX, you might want to have a look at m202docker , which allows you to run MongoDB in a (thin) virtualized environment. There are other Docker images for MongoDB as well.
Disclaimer: I created the m202docker image, so I am propably biased
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.