在cmd中使用命令能够登录MongoDB,然后改用MongoVUE就一直提示:Connection was refuse


日志文件上描述:

UserNotFound Could not find user admin1@diva
2015-10-13T12:12:22.208+0800 I NETWORK  [conn1] end connection 127.0.0.1:49323 (0 connections now open)
2015-10-13T12:12:24.208+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:49325 #2 (1 connection now open)
2015-10-13T12:12:24.209+0800 I ACCESS   [conn2]  authenticate db: diva { authenticate: 1, user: "admin", nonce: "xxx", key: "xxx" }
2015-10-13T12:12:24.209+0800 I ACCESS   [conn2] Failed to authenticate admin1@diva with mechanism MONGODB-CR: AuthenticationFailed 



解决办法:

1、停止MongoDB的服务,将注册表中的配置认证(--auth)去掉;

cmd中输入regedit,到注册表,找到以下路径:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MongoDB




2、再次启动MongoDB的服务,打开CMD,输入mongo


3、依次输入以下命令:

var schema = db.system.version.findOne({"_id" : "authSchema"}) 
schema.currentVersion = 3
db.system.version.save(schema)


然后得到: WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })



4、删除原来的用户db.removeUser("admin")

db.removeUser("admin")


5、重新创建:

db.createUser(  
    {  
        "user": "admin",  
        "pwd": "****",  
        "roles":[  
            {  
                "role": "dbOwner",  
                "db": "diva"  
            }  
        ]  
    }  
)  
并认证:

db.auth('admin','****')


好了后再回到MongoVUE就登陆成功了~太棒了,给自己点个赞 大笑


Logo

前往低代码交流专区

更多推荐