我用身份验证设置了副本集.我用了this英镑.我设置了keyfile、admin用户和其他用户.一切正常——匿名访问被禁用,我可以登录
$ 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
使用相同的凭证.我在文档或这里没有找到任何有用的东西.