MongoDB连接auth适用于shell,但不适用于外部工具

时间:2015-04-02 14:21:41

标签: mongodb intellij-idea authorization spring-data-mongodb robo3t

我遇到一个问题,我无法使用Spring Data MongoDB抽象通过MongoShell或我的webapp从外部Tootls连接到MongoDB。

我已成功为MongoDB上的'mydb'数据库创建了一个用户 我可以使用命令

连接到我的localhost上的MongoDb
$ mongo mydb -u alex -p 12345678 --host localhost --port 27017

MongoDB shell version: 3.0.1
connecting to: localhost:27017/mydb
> show users
{
    "_id" : "mydb.alex",
    "user" : "alex",
    "db" : "mydb",
    "roles" : [
        {
            "role" : "readWrite",
            "db" : "mydb"
        }
    ]
}

现在我可以插入集合和查询,一切看起来都很流畅。 我也可以从我的web-app连接Spring Data MongoDB抽象。

当我现在尝试使用正确的主机,端口,数据库,用户名和密码使用Robomongo应用程序或Intellij Plugin连接MongoDB时,我收到授权错误

来自Intellij

Error when collecting Mongo databases: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}

来自Robomongo

2015-04-02 16:00:30: Connecting to localhost:27017...
2015-04-02 16:00:30: connect failed
2015-04-02 16:00:30: Unable to authorize

我想使用一些GUI客户端来获得更好的可视化和CRUD操作支持,但目前我无法连接到MongoDB

你知道这是什么原因吗?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,在mongoDb日志中我看到了:

无法使用MONGODB-CR机制验证xxx @ yyyy:用户文档中缺少AuthenticationFailed MONGODB-CR凭证

我相信这篇文章MongoDB-CR Authentication failed解释了如何设置旧的身份验证。您需要删除现有用户并再次添加新用户。