不想以`sudo mongod`开始mongod [英] Dont want to have to start mongod with `sudo mongod`

查看:160
本文介绍了不想以`sudo mongod`开始mongod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过brew install mongodb将mongodb下载到了OS X 10.9.5全新的MacBookAir上.

I just downloaded mongodb onto my brandy new MacBookAir with OS X 10.9.5 by doing brew install mongodb.

我试图从Terminal运行mongod,它说"no/data/db",所以我用sudo mkdir /datasudo mkdir /data/db创建了它.

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.

现在正在运行mongod,我得到无法创建/打开锁定文件:/data/db/mongod.lock errno:13权限被拒绝",但是我可以使用sudo mongod完美地运行它.

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.

如何做到这一点,这样我就不必用sudo运行mongod了,而是像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.)

推荐答案

这对我有用:

sudo chmod -R 777 /data/db

然后

sudo chown -R `id -u` /data/db

-R使命令递归;我以前曾按照其他StackOverflow答案中的说明尝试过sudo chmod 777 /data/dbsudo chown `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,很抱歉,我知道这是一个非常老的问题,但是我在寻找问题的答案时发现了它;并且由于我设法解决了这个问题,所以我想我会把这个放在这里给任何人未来.我也不知道这两个命令中的哪一个有所作为,但它确实有效.)

(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.)

这篇关于不想以`sudo mongod`开始mongod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆