DBA管理著資料庫所有的資料,但對某些資料的操作,因為審計或其它原因,用管理員身份可能並不方便,但你又不知道方便的那個Oracle使用者的使用者密碼是多少,因為Oracle的使用者密碼是加密了的。那有沒辦法不用知道密碼的情況下,借用下別的Oracle使用者身份來玩玩,弄完了再還回去呢?當然有法子的。 看我來怎麼弄。
例子用8i測的,但11g版本後有個新變化,密碼加密字串放user$了,需要去user$中查出:
SQL> select * from v$version;
/c clsBANNER
----------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
SQL> create user test identified by test;
使用者已建立
SQL> SELECT password FROM dba_users WHERE username='TEST';
/c clsPASSWORD
------------------------------
7A0F2B316C212D67
SQL> alter user test identified by newpwd;
使用者已更改。
SQL> SELECT password FROM dba_users WHERE username='TEST';
/c clsPASSWORD
------------------------------
39797952BFEE21C3
SQL> grant connect,resource to test;
授權成功。
上面建了個test使用者,原來的密碼是test,後改成了newpwd. 這裡注意下,密碼test加密後的字串為"7A0F2B316C212D67".
再開另一個會話測試連接:
C:\>sqlplus /nolog
SQL*Plus: Release 8.1.7.0.0 - Production on 星期四 3月 13 15:37:54 2014
(c) Copyright 2000 Oracle Corporation. All rights reserved.
SQL> connect test/test@xcldb
ERROR:
ORA-01017: invalid username/password; logon denied
SQL> connect test/newpwd@xcldb
ERROR:
ORA-01045: user TEST lacks CREATE SESSION privilege; logon denied
SQL> connect test/newpwd@xcldb
已串連。
SQL> disconnect;
證明新密碼是生效的。
嘗試把密碼改回為舊的"test",看下面怎麼弄的。
有木有,神奇的密碼字串又回來了。
再測試下:
SQL> disconnect;
從Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production中斷開
SQL> connect test/newpwd@xcldb
ERROR:
ORA-01017: invalid username/password; logon denied
SQL> connect test/test@xcldb
已串連。
SQL>
嗯,又可以用舊的密碼test登入了。
這技巧純玩玩,別亂搞。