我在 osx 上运行 mongo 2.2.2。
当我执行以下身份验证时,一切正常:
$ mongo
>> use admin
>> db.auth("uname", "password")
日志:
Thu Mar 7 13:51:08 [initandlisten] connection accepted from 127.0.0.1:63474 #10 (4 connections now open)
Thu Mar 7 13:51:08 [conn10] authenticate db: admin { authenticate: 1, nonce: "123", user: "uname", key: "456" }
但是,当我尝试直接从命令行进行身份验证时:
$ mongo admin -u uname -p password
我收到以下错误:
Thu Mar 7 14:25:52 [initandlisten] connection accepted from 127.0.0.1:63939 #12 (5 connections now open)
Thu Mar 7 14:25:52 [conn12] authenticate db: admin { authenticate: 1, nonce: "789", user: "uname", key: "147" }
Thu Mar 7 14:25:52 [conn12] auth: key mismatch uname, ns:admin
Thu Mar 7 14:25:52 [conn12] end connection 127.0.0.1:63939 (4 connections now open)
有谁知道这是什么原因?