收到一個監控使用者無法串連資料庫的警示, Oracle提示錯誤訊息ORA-28001: the password has expired, 上去查看使用者狀態竟然是expired,擷取使用者基本資料指令碼如下:
connect / as sysdba;
col username for a16
col password for a18
col user_id for 999999
col account_status heading 'Account|Status' for a20
col default_tablespace heading 'Default|Tablespace' for a25
col temporary_tablespace heading 'Temporary|Tablespace' for a12
set lines 125
set pages 100
select username,user_id,password,account_status,default_tablespace,temporary_tablespace,to_char(created,'yyyy-mm-dd hh24:mi:ss') created
from dba_users
order by username;
這是Oracle11G的一個新特性, Oracle11G建立使用者時預設密碼到期限制是180天, 如果超過180天使用者密碼未做修改則該使用者無法登入。
查看PROFILE設定
select * from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
DEFAULT PASSWORD_LIFE_TIME PASSWORD 180
處理邏輯,將使用者密碼修改並判斷是否需要這個策略
ALTER USER 使用者名稱 IDENTIFIED BY 密碼 ;
語句進行修改密碼,密碼修改後該使用者可正常串連資料庫。
如果需要修改策略
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED
語句將口令有效期間預設值180天修改成“無限制”。