在日常的数据库维护过程中,有很多朋友为了权限赋予的方便,一般都会直接赋予新建用户dba角色。dba这个角色是数据库中权限非常大的,这里我们来看看如何通过一个dba角色来获得sysdba权限。
在dba角色的权限列表中有一项:alter user权限,这个权限可以允许我们修改数据库所有用户账户信息,包括sys用户的。
>alter user sys identified by mypassword;
这样修改之后你会发现,你可以使用修改后的密码来登入sys,这样你就获得了sys的权限。有时候由于sys密码频繁修改,或者长时间不用,导致密码丢失可以用这种方法很好的解决。 当然,如果觉得直接去修改原先的sys密码会很不安全,因为这会引起管理员的注意,只是需要使用之后再还回去,但又不知道原先的密码,不能通过上面的语句 修改回去,这个时候,可以用alter user 的另一个语句来实现
>alter user sys identified by values 's1213asdwe';
下面是个修改过程的例子。
SQL*Plus: Release 10.1.0.3.0 - Production on Wed Jun 30 19:41:28 2010 Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> conn Enter user-name: justay
Enter password:
Connected.
SQL> select username,password from dba_users where username='SYS'; USERNAME PASSWORD -----------------
SYS 4001B8AE29A7B401
SQL> alter user sys identified by oracle;
User altered.
SQL> disconn
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL> conn
Enter user-name: sys as sysdba
Enter password:
Connected.
SQL> create user hideac identified by oracle;
User created.
SQL> grant sysdba to hideac;
Grant succeeded.
SQL> disconn
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL> conn
Enter user-name: justay
Enter password: Connected.
SQL> alter user sys identified by values '4001B8AE29A7B401'; --将sys用户密码还原 User altered.
从上面可以看出在拥有dba权限的情况下,新建了一个拥有sysdba权限的用户hideac。 这个现象告诉我们
1.不要轻易给一个用户dba权限。
2.如果非要给dba权限,请修改sys为OS验证,并确保数据库服务器操作系统口令的安全
3.当然,也可以revoke掉dba的grant权限和alter user权限
SQL>revoke alter user from dba
SQL>revoke grant any role from dba
SQL>revoke grant any privilege from dba
SQL>revoke grant any object privilege from dba
在dba角色的权限列表中有一项:alter user权限,这个权限可以允许我们修改数据库所有用户账户信息,包括sys用户的。
>alter user sys identified by mypassword;
这样修改之后你会发现,你可以使用修改后的密码来登入sys,这样你就获得了sys的权限。有时候由于sys密码频繁修改,或者长时间不用,导致密码丢失可以用这种方法很好的解决。 当然,如果觉得直接去修改原先的sys密码会很不安全,因为这会引起管理员的注意,只是需要使用之后再还回去,但又不知道原先的密码,不能通过上面的语句 修改回去,这个时候,可以用alter user 的另一个语句来实现
>alter user sys identified by values 's1213asdwe';
下面是个修改过程的例子。
SQL*Plus: Release 10.1.0.3.0 - Production on Wed Jun 30 19:41:28 2010 Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> conn Enter user-name: justay
Enter password:
Connected.
SQL> select username,password from dba_users where username='SYS'; USERNAME PASSWORD -----------------
SYS 4001B8AE29A7B401
SQL> alter user sys identified by oracle;
User altered.
SQL> disconn
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL> conn
Enter user-name: sys as sysdba
Enter password:
Connected.
SQL> create user hideac identified by oracle;
User created.
SQL> grant sysdba to hideac;
Grant succeeded.
SQL> disconn
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL> conn
Enter user-name: justay
Enter password: Connected.
SQL> alter user sys identified by values '4001B8AE29A7B401'; --将sys用户密码还原 User altered.
从上面可以看出在拥有dba权限的情况下,新建了一个拥有sysdba权限的用户hideac。 这个现象告诉我们
1.不要轻易给一个用户dba权限。
2.如果非要给dba权限,请修改sys为OS验证,并确保数据库服务器操作系统口令的安全
3.当然,也可以revoke掉dba的grant权限和alter user权限
SQL>revoke alter user from dba
SQL>revoke grant any role from dba
SQL>revoke grant any privilege from dba
SQL>revoke grant any object privilege from dba