如何在2.6中将管理员用户添加到Mongo?

编程入门 行业动态 更新时间:2024-10-25 17:17:10
本文介绍了如何在2.6中将管理员用户添加到Mongo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从2.4升级到2.6,身份验证失败. 本教程看起来很简单,但我一直被自己的数据库所束缚.我的情况很简单,我只有一台Mongo服务器,需要一个用户/密码组合才能连接.

I upgraded from 2.4 to 2.6 and authentication broke. This tutorial seems pretty straightforward but I keep getting locked out of my own database. My situation is pretty simple, I have a single Mongo server and need one user/pwd combination to connect.

首先,我通过提到的localhost异常进行连接.然后,按照建议创建管理员用户:

First I connect via the localhost exception as mentioned. Then I create the admin user as suggested:

use admin db.createUser( { user: "myadmin", pwd: "mysecret", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )

现在是时候添加新用户了,所以为了健全起见,我注销了shell.现在,当我键入"mongo"时,它将失败.过去可以正常工作,但是没关系,它没有看到用户名密码,并且我猜本地主机异常不再存在,所以我按照此处:

Now it's time to add new users so to sanity check myself, I logout of the shell. Now when I type "mongo" it fails. That used to work but OK, it's not seeing a username password and I guess the localhost exception isn't there anymore so I follow the instructions outlined here:

mongo --port 27017 -u myadmin -p mysecret --authenticationDatabase admin

然后我得到:

MongoDB shell version: 2.6.0 connecting to: 127.0.0.1:27017/test Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" } >

有关如何操作的任何想法

Any idea on how to:

  • 安装Mongo 2.6,这样我就可以轻松地进入和退出管理数据库的外壳程序(我认为这是系统用户管理员")

  • Setup Mongo 2.6 so I can easily go in and out of the shell managing the databases (I would think this is the "system user administrator")

    是否允许来自远程客户端的用户进行连接? (只是mongo方面,不需要iptables的帮助...)

    Enable a user from a remote client to connect? (Just the mongo side, no help needed with iptables ...)

    谢谢!

    推荐答案

    显然,系统用户管理员"还不够.创建一个root用户:

    Apparently the "system user administrator" isn't enough. Create a root user:

    > db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})

    然后添加您的数据库用户:

    Then add your database user:

    > use some_db > db.createUser( { user: "mongouser", pwd: "someothersecret", roles: ["readWrite"] } )

    有关此要点的更多详细信息.对要点的评论和对SO欢迎的更好答案-我不是系统管理员

    More details on this gist. Comments on gist and better answers on SO welcome - I'm not a sys admin

  • 更多推荐

    如何在2.6中将管理员用户添加到Mongo?

    本文发布于:2023-11-22 19:11:32,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1618655.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:中将   管理员   用户   如何在   Mongo

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!