MongoDB学习笔记(四) MongoDB用户权限基本操作

查看当前数据库的全部用户

复制代码
>  show users
{
        
" _id "  : ObjectId( " 4dedeeae26e7516d69948e33 " ),
        
" user "  :  " libing " ,
        
" readOnly "  : false,
        
" pwd "  :  " 541025c56e577050c3e44efb105e28b6 "
}
复制代码

 

>  db.system.users.find()
" _id "  : ObjectId( " 4dedeeae26e7516d69948e33 " ),  " user "  :  " libing " " readOnly "  : false,  " pwd "  :  " 541025c56e577050c3e44efb105e28b6 "  }

 

添加用户 

复制代码
>  db.addUser( " libing " , " 1 " )
{
        
" user "  :  " libing " ,
        
" readOnly "  : false,
        
" pwd "  :  " d9d8e958e0f1d1a0e1a204f85f9ef1b3 "

复制代码

 

复制代码
>  db.addUser( " libing " , " 1 " ,true)
{
        
" user "  :  " libing " ,
        
" readOnly "  : true,
        
" pwd "  :  " d9d8e958e0f1d1a0e1a204f85f9ef1b3 "


复制代码

 

用户认证

>  db.auth( " libing " , " 1 " )
1

 

删除用户 

>  db.removeUser( " libing " )
 
 

你可能感兴趣的:(mongodb,权限操作)