关于MONGODB 用户认证问题

边城cn 2014-03-28 01:48:21
我在非ADMIN数据库中,添加一个用户,登录时,就会出一个错误:
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }


哪位知道怎么解决的????请指教!


#1,添加用户:

> use mdsp
switched to db mdsp
> db.addUser("u1","u1");
WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead
Successfully added user: { "user" : "u1", "roles" : [ "dbOwner" ] }

#用户认证
> db.auth("u1","u1")
1
>

在另一窗口进行登录测试:

#3 刚加完用户后,登录:
[mongo@localhost ~]$ cd $MONGO_HOME/bin
[mongo@localhost bin]$ ./mongo localhost:28001/mdsp -u u1 -p u1
MongoDB shell version: 2.5.5
connecting to: localhost:28001/mdsp
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }

看到这个错误出来了。


> exit
bye

#4 在用户认证后,再登录。问题依然存在:
[mongo@localhost bin]$ ./mongo localhost:28001/mdsp -u u1 -p u1
MongoDB shell version: 2.5.5
connecting to: localhost:28001/mdsp
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }
>
#版本为:
> version()
2.5.5
>

...全文
735 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
HuiliQin 2014-04-10
  • 打赏
  • 举报
回复
在每次启动mongo shell的时候,mongo shell都会运行以下命令来获取所连接的mongod进程启动时的警告信息

db.adminCommand( { getLog : "startupWarnings" } );
如果mongod是在验证的模式下运行,需要用户有admin数据库的权限来运行上面的命令,否则就会报错: Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" } mongo shell启动时的这个错误信息只是表示这个用户无法读取mongod进程启动时报的警告,是可以忽略的。你应该是可以继续使用mongo shell的。 还有几点需要提醒的是: 1. 2.5.5是一个开发版本,不要在生产环境中使用。 2. MongoDB 2.5/2.6版本引入了新的用户验证模式,推荐阅读以下文档了解2.5/2.6中的变化: http://docs.mongodb.org/manual/release-notes/2.6/#security-improvements

1,746

社区成员

发帖
与我相关
我的任务
社区描述
MongoDB相关内容讨论区
社区管理员
  • MongoDB社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧