美文网首页
#4 mongodb 使用注意点

#4 mongodb 使用注意点

作者: JamesSawyer | 来源:发表于2017-06-26 18:46 被阅读31次

1.没有权限

开启验证之后,再使用命令行,会报没有权限的错误,这是因为在使用命令行之前需要先验证一下

注意一点, 帐号是跟着库走的,所以在指定库里授权,必须也在指定库里验证(auth)。

# 假设admin开启了权限验证
# 帐号为 'root', 密码: '123456', roles: ['role': 'root']
> use admin
> show dbs
{
       "ok" : 0,     
       "errmsg" : "not authorized on example to execute command  dbstats: 1.0, scale: undefined }",
       "code" : 13,  
       "codeName" : "Unauthorized"    
}

## 使用命令行之前先验证一次
> db.auth('root', '123456')
1
> db.system.users.find().pretty()   // ok

具体

相关文章

网友评论

      本文标题:#4 mongodb 使用注意点

      本文链接:https://www.haomeiwen.com/subject/xxvjcxtx.html