1)我按照此处(3)描述的方式创建了管理员用户: http://docs.mongodb.org/manual/tutorial/add-user-administrator/ 2)然后,我取消注释 mongod.conf 文件中的以下行: auth = true 3)最后,我重启了 mongod 服务,并尝试使用以下命令登录: /usr/bin/mongo localhost:27017/admin -u sa -p pwd
4)我可以连接,但它在连接时显示以下内容。
MongoDB shell version: 2.6.1
connecting to: localhost:27017/admin
Welcome to the MongoDB shell!
The current date/time is: Thu May 29 2014 17:47:16 GMT-0400 (EDT)
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }
5) 现在看起来我创建的这个sa
用户完全没有权限。
root@test02:~# mc
MongoDB shell version: 2.6.1
connecting to: localhost:27017/admin
Welcome to the MongoDB shell!
The current date/time is: Thu May 29 2014 17:57:03 GMT-0400 (EDT)
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }
[admin] 2014-05-29 17:57:03.011 >>> use admin
switched to db admin
[admin] 2014-05-29 17:57:07.889 >>> show collections
2014-05-29T17:57:10.377-0400 error: {
"$err" : "not authorized for query on admin.system.namespaces",
"code" : 13
} at src/mongo/shell/query.js:131
[admin] 2014-05-29 17:57:10.378 >>> use test
switched to db test
[test] 2014-05-29 17:57:13.466 >>> show collections
2014-05-29T17:57:15.930-0400 error: {
"$err" : "not authorized for query on test.system.namespaces",
"code" : 13
} at src/mongo/shell/query.js:131
[test] 2014-05-29 17:57:15.931 >>>
什么是问题?我已经按照MongoDB文档的规定重复了这个过程3次,但它不起作用。我期望这个"sa"用户被授权做任何事情,以便他可以创建其他用户并给他们更具体的权限。