sys臨時修改其他未知使用者密碼 alter user identified by values ”

東北胖子發表於2018-06-25

其實是可以的,需要先記錄下當前密碼的hash 值,修改為新的,用完以後再改回來,神不知鬼不覺,風險是anbob真實使用者會在這段時間無法登入.
ORACLE在pre-11g,11g, 12c 使用了不同的密碼策略, 所以要對應用相應的版本修改.
11g以前版本的修改方法
用alter user identified by values命令很方便

[oracle@orazhang ~]$ ora

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 9月 22 10:42:07 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

--此時anbob密碼是anbob
sys@ORCL> select NAME,PASSWORD from user$ where name='ANBOB';
NAME                           PASSWORD
------------------------------ ------------------------------
ANBOB                          ACF67A552551E848

sys@ORCL> alter user anbob identified by anbob123;
User altered.

sys@ORCL> select NAME,PASSWORD from user$ where name='ANBOB';
NAME                           PASSWORD
------------------------------ ------------------------------
ANBOB                          64096627C6DB8EEA

sys@ORCL> conn anbob/anbob123
Connected.
anbob@ORCL> select 'do something' from dual;

'DOSOMETHING
------------
do something

anbob@ORCL> conn / as sysdba
Connected.

anbob@ORCL> alter user anbob identified by values 'ACF67A552551E848';

sys@ORCL> conn anbob/anbob
Connected.

11g版本的修改方法
sec_case_sensitive_logon引數控制著密碼是否啟用了大小寫敏感.

#11g版本 DBA_USERS檢視增加了一列PASSWORD_VERSIONS, 記錄了當前的密碼使用是哪種hash演算法, 如果是11G,新的hash值會記錄在user$.spare4欄位. 如果查之前的dba_user.password將為NULL.

1,
SQL> select spare4 from user$ where name='ANBOB';
--remeber the values

2, SQL> alter user anbob identified by [newvalue]

3, SQL> alter user anbob identified by values [#1 spare4 value]

# 記錄當前的所有使用者密碼

select 'alter user '||name||' identified by values '''||password||''';' from user$ where spare4 is null and password is not null
union
select 'alter user '||name||' identified by values '''||spare4||';'||password||''';' from user$ where spare4 is not null and password is not null;

12c# 版本好像是又增加了密碼了新的HASH 演算法.

note: 不建議修改基表在生產庫中,無論什麼時候

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2317695/viewspace-2156591/,如需轉載,請註明出處,否則將追究法律責任。

相關文章