如何在 Ubuntu 10.04 中使用 --auth 选项重新启动 mongodb?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6235808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I restart mongodb with --auth option in Ubuntu 10.04?
提问by user482594
Well, restarting works with stop and start command, but I cannot seem to execute the mongodb command with --auth option.
好吧,重新启动可以使用 stop 和 start 命令,但我似乎无法使用 --auth 选项执行 mongodb 命令。
root@random:/home/random/public_html# mongodb stop
root@random:/home/random/public_html# start mongodb --auth
start: invalid option: --auth
root@random:/home/random/public_html# start mongodb
mongodb start/running, process 29473
root@random:/home/random/public_html#
How can I start mongodb with --auth option?
如何使用 --auth 选项启动 mongodb?
回答by Scott Hernandez
Edit /etc/mongod.conf
and add a line like this:
编辑/etc/mongod.conf
并添加如下一行:
auth=true
Then:
然后:
service mongod restart
See this page for more configuration options: http://www.mongodb.org/display/DOCS/File+Based+Configuration
有关更多配置选项,请参阅此页面:http: //www.mongodb.org/display/DOCS/File+Based+Configuration
For MongoDB latest versions 3.x above code wont work, below code in mongod.conf if you are using mongodb 3.x
对于 MongoDB 最新版本 3.x,上面的代码不起作用,如果您使用的是 mongodb 3.x,则在 mongod.conf 中的下面的代码
security:
authorization: enabled
回答by Chiedo
If you are using MongoDB 3, setting auth = true
wont work. You will instead need the following in your /etc/mongod.conf
如果您使用的是 MongoDB 3,则设置将auth = true
不起作用。您将需要在 /etc/mongod.conf 中进行以下操作
security:
authorization: enabled
回答by Akarsh Satija
For mongodb version 3.2
对于 mongodb 3.2 版
this is the correct config
这是正确的配置
security:
authorization: "enabled"
in String format
字符串格式
回答by Joseph Hui
Just want to supplement the answer. For MongoDB 3, the /etc/mongod.conf has changed. Either of below enable MondgoDB authorization option (--auth):
只是想补充答案。对于 MongoDB 3,/etc/mongod.conf 已更改。以下任一启用 MondgoDB 授权选项 (--auth):
security: keyFile: [The path to a key file]
security: keyFile: [密钥文件的路径]
-- or--
- 或者 -
security: authorization: enabled
安全:授权:启用
回答by Joseph Hui
you should put the --auth
option in the startup script
你应该把--auth
选项放在启动脚本中
/etc/rc[0-6].d/mongod