我设置了具有身份验证的副本集.我用过这个教程.我设置了密钥文件,管理员用户和其他用户.一切正常 - 匿名访问被禁用,我可以登录
$ mongo MongoDB shell version: 2.6.1 connecting to: test Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" } rs0:PRIMARY> use admin switched to db admin rs0:PRIMARY> db.auth("USERNAME","PASSWORD") 1 rs0:PRIMARY>
使用我创建的用户凭据.
但我无法从命令行登录
$ mongo -u 'USERNAME' -p 'PASSWORD' MongoDB shell version: 2.6.1 connecting to: test 2014-05-18T14:23:47.324+0200 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210 exception: login failed
使用相同的凭据.我没有在文档中找到任何有用的信息,或者在SO上找到.