用户管理

Posted think的海角

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用户管理相关的知识,希望对你有一定的参考价值。

1、创建用户:

conn system/password01;

create user username01 identified by password001;//新创建的用户,没有登录权限

grant connect to username01;//connect 实际是角色

2、修改密码

password;//修改当前用户的密码

password username01;//修改指定用户的密码

3、删除用户(自己不能删自己,具有drop user权限的用户就具有删除用户的功能)

drop user username01 [cascade]//cascade 添加这个参数,会删除该用户及其创建的表

4、授予权限

授予创建表的权限

grant resource to username01;//授予创建表的权限,resource具有创建表的权限

create table test(userId varchar2(30), userName varchar2(30));

desc test;//查表结构

授予操作表的权限

conn scott/tiger;

grant select on emp to hbl1;//授予选择权限,授予所有权限select all on emp to hbl1;

conn hbl1/hbl1;

select * from scott.emp;//这里一定要有用户,如scott

5、收回权限(谁授予谁收回)

conn scott/tiger;

revoke select on emp from hbl1;

6、权限的传递

conn scott/tiger;

--如果是对象权限,添加with grant option;如果是系统权限,添加 with admin option,如grant connect to hbl2 with admin option;

grant select on emp to hbl1 with grant option;//hbl1具有将select权限传递下去的权限

conn system/Gauss_234;

create user hbl2 identified by hbl2;

grant connect to hbl2;

conn hbl1/hbl1;

grant select on scott.emp to hbl2;

conn hbl2/hbl2;

select * from scott.emp;

--scott 回收了hbl1的select权限,同时也就回收了hbl2的select权限

7、用户口令管理(profile配置文件)

--hbl2 尝试三次登录,失败锁2天

create profile account_lock1 limit failed_login_attempts 3  password_lock_time 2;

alter user hbl2 profile account_lock1;

--解锁

conn system/Gauss_234;

alter user hbl2 account unlock;

--删除profile

drop profile profileName [cascade]--cascade约束的对象,约束关系也删掉

附:权限及角色,角色是批量的权限

 

以上是关于用户管理的主要内容,如果未能解决你的问题,请参考以下文章

MySQL的用户管理与权限管理

MySQL的用户管理与权限管理

Linux学习之用户管理命令与用户组管理命令(十五)

怎么在我的电脑里添加管理员用户

18. 用户与权限管理

金蝶KIS软件用户管理及权限授权