`
jayghost
  • 浏览: 440075 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

How To Change/Restore User Password in 11G

 
阅读更多

Oracle 11g introduces Case-sensitive passwords for database authentication. Along with this if you wish to change the password (temporarily) and reset it back to old , you will find that password field in dba_users is empty. Prior to 11g we could use following technique to change/restore password

SQL> create user amit identified by amit;

User created.

SQL> grant create session to amit;

Grant succeeded.

SQL> conn sys as sysdba
Enter password:
Connected.
SQL> select username,password from dba_users where username='AMIT';

USERNAME                       PASSWORD
------------------------------ ------------------------------
AMIT                           9DEC0D889E8E9A6B

SQL> alter user amit identified by abc;

User altered.

SQL> conn amit/abc
Connected.
SQL> conn sys as sysdba
Enter password:
Connected.
SQL> alter user amit identified by values '9DEC0D889E8E9A6B';

User altered.

SQL> conn amit/amit
Connected.

In 11g if you query password field, it will return NULL.

SQL> select username,password from dba_users where username='AMIT';

USERNAME                       PASSWORD
------------------------------ ------------------------------
AMIT

Let’s first see Case-sensitive password feature in 11g and then steps to change/restore passwords

SQL> create user amit identified by AMIT;

User created.

SQL> grant connect,resource to amit;

Grant succeeded.

SQL> conn amit/amit
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
SQL> conn amit/AMIT
Connected.

This behavior is controlled by “sec_case_sensitive_logon” initialization paramter. If the value is true then it will enforce case sensitive passwords

SQL> select NAME,VALUE from V$SPPARAMETER where NAME='sec_case_sensitive_logon';

NAME                                     VALUE
---------------------------------------- --------------------
sec_case_sensitive_logon                 TRUE

SQL> conn / as sysdba
Connected.
SQL> alter system set sec_case_sensitive_logon=false;

System altered.

SQL> conn amit/amit
Connected.
SQL> conn / as sysdba
Connected.
SQL> alter system set sec_case_sensitive_logon=true;

System altered.

SQL> conn amit/amit
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
SQL> conn amit/AMIT
Connected.

Now to reset the password in 11g, we need to query spare4 column in user$ table

SQL> select spare4 from user$ where name='AMIT';

SPARE4
--------------------------------------------------------------------------------
S:2D058976AE8FAD8ECFCDB93835ACEE94C83EDE19169209155BB81FEE7DBB

SQL> alter user amit identified by abc12;

User altered.

SQL> conn amit/abc12
Connected.
SQL> conn / as sysdba
Connected.
SQL> alter user amit identified by values 'S:2D058976AE8FAD8ECFCDB93835ACEE94C83EDE19169209155BB81FEE7DBB';

User altered.

SQL> conn amit/abc12
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
SQL> conn amit/AMIT
Connected.

As per Metalink Note 429465.1 , view DBA_USERS has new column PASSWORD_VERSIONS rendered as follows:

decode(length(u.password),16,'10G ',NULL)||NVL2(u.spare4, '11G ' ,NULL)
for example:

SQL> select USERNAME, PASSWORD_VERSIONS from dba_users where rownum <5;

USERNAME                       PASSWORD
------------------------------ --------
SYS                            10G 11G
SYSTEM                         10G 11G
OUTLN                          10G 11G
DIP                            10G 11G

In this case it means both old and new-style hash values are available for the users, the new hash value is stored in the USER$.SPARE4 column, as long as this remains NULL it means the password has not been changed since the migration and the user will have the old case insensitive password.

SQL> create user test identified by test;

User created.

SQL> select USERNAME, PASSWORD_VERSIONS from dba_users where username in (‘AMIT’,'TEST’);

USERNAME                       PASSWORD
—————————— ——–
AMIT                           11G
TEST                           10G 11G

As I had reset password using only spare4 string, password will be case -sensitive irrespective of setting for sec_case_sensitive_logon parameter value. i.e why we see value of “11G”  for user Amit.

Update

When resetting the password, we need to also query password column from user$ column if we wish to use case-insensitive feature in future. i.e In my above example I used only spare4 column value to reset the password. Now if I set sec_case_sensitive_logon=false , I will not be able to connect.

SQL> alter system set sec_case_sensitive_logon=false;

System altered.

SQL> conn amit/amit
ERROR:
ORA-01017: invalid username/password; logon denied

In case we wish to use both, we need to set identified by values ‘S:spare4;password’. As I didnot use password field while resetting, I find that password field in user$ is empty. To correct it, I had to change the password again.

SQL> select password,spare4 from user$ where name='AMIT';

PASSWORD                       SPARE4
------------------------------ ----------------------------------------------------------------------
                               S:2D058976AE8FAD8ECFCDB93835ACEE94C83EDE19169209155BB81FEE7DBB

SQL>  alter system set sec_case_sensitive_logon=true;

System altered.

SQL> alter user amit identified by AMIT;

User altered.

SQL> select password,spare4 from user$ where name='AMIT';

PASSWORD                       SPARE4
------------------------------ ----------------------------------------------------------------------
9DEC0D889E8E9A6B               S:F5DEBF680433864AA5A744C2368D8677A120939D083D74A2F6E99C5952AE

So to reset the password, following needs to be used.

SQL> select password,spare4 from user$ where name='AMIT';

PASSWORD                       SPARE4
------------------------------ ----------------------------------------------------------------------
9DEC0D889E8E9A6B               S:F5DEBF680433864AA5A744C2368D8677A120939D083D74A2F6E99C5952AE

SQL> alter user amit identified by values 'S:F5DEBF680433864AA5A744C2368D8677A120939D083D74A2F6E99C5952AE;9DEC0D889E8E9A6B';

User altered.

Thanks to Laurent for pointing this. You can see his article for more information.You can use below code to get the password script

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;

 

分享到:
评论

相关推荐

    UE(官方下载)

    This tutorial will show you how to access the information you need in your browser by simply highlighting your text in the edit window and clicking your toolbar button How to install UE3 UE3 is the ...

    docker-oracle-xe-11g:Oracle Database Express Edition 11g第2版的Dockerfile

    docker-oracle-xe-11g Ubuntu 18.04 LTS上的Oracle...+ the old [wnameless/oracle-xe-11g] is banned by DockerHub and I cannot restore it. + Thanks for the help from the staff in Oracle with my DMCA Takedown

    uPi Linux disk to backup / restore-开源

    一个易于使用的磁盘制造商和单磁盘 Linux,能够备份和恢复工作站(分区/文件)到/从 FTP 或 partimage 服务器(s)。 非常适合具有几个工作站和只有一台服务器的小型实体。 或者备份你的电脑。

    Oracle从10g升级到11g详细步骤

    本文档依据metalink详细介绍了 Oracle从10g升级到11g详细步骤,以及各项需要注意的地方

    delphi 7 gif控件

    // How to use: Set the Animate property to False and set the ForceFrame // // property to a desired frame number (0-N) // // Normal display: Set the ForceFrame property to -1 and set Animate to True. ...

    Dump/Restore ext2/3/4 filesystem backup-开源

    "Dump/Restore"工具就是针对这些文件系统设计的一套开源备份解决方案。本文将详细讲解dump和restore命令的功能、使用方法以及其在备份和恢复过程中的作用。 "Dump"是一个功能强大的命令行工具,它允许用户对Linux...

    oracle_dmp.rar_DMP_oracle

    GRANT CREATE SESSION, CREATE TABLE, CREATE SYNONYM, CREATE VIEW, CREATE SEQUENCE, CREATE INDEX TO RESTORE_USER; ALTER USER RESTORE_USER QUOTA UNLIMITED ON users; ALTER USER RESTORE_USER TEMPORARY ...

    Oracle 11g rman 异机还原再升级到 12c PDB

    ### Oracle 11g RMAN 异机还原再升级到 12c PDB #### 背景介绍 在企业级应用环境中,数据库的迁移与升级是一项常见但又复杂的工作。本文档详细记录了从Oracle 11.2.0.4版本数据库通过RMAN工具进行异地备份恢复,并...

    Oracle 11G Client 客户端安装步骤.docx

    Oracle 11G 客户端安装步骤 Oracle 11G 客户端安装是指在客户端计算机上安装 Oracle 11G 客户端软件的过程。客户端安装是指用户在自己的计算机上安装 Oracle 客户端软件,以便与远程 Oracle 服务器连接并进行数据...

    Oracle-使用RMAN从10g直接迁移到11G

    Oracle-使用RMAN-将-DB-从10g-直接-Restore-到11g-示例

    jenkins-user-handbook

    If you want to get up and running with Jenkins, see ...If you are a system administrator and want learn how to back-up, restore, maintain as Jenkins servers and nodes, see Jenkins System Administration.

    Oracle使用RMAN将DB从10g直接Restore到11g示例.pdf

    oracle rman深入学习研究的文章,很不错的

    LMD.StoragePack.v1.06.30.For.Delphi

    Other key features are: Allows use of Windows Registry and general formats (BIN-, INI- and XML-files - more to come in future versions) Supports saving/restoring data to/from binary streams Allows ...

    用SCANREG程序恢复正常注册表

    5. **复制备份文件**:从备份文件夹中(通常是C:\Windows\Backup)将system.dat.bak和user.dat.bak复制回Windows目录,并重命名为system.dat和user.dat。 6. **恢复属性**:再次使用`attrib +s +h +r system.dat`和`...

    delphi2010皮肤控件-VCLSkinv5.30FS

    News In 4.82 05/11/2007 *Improve image quality of form icon. News In 4.81 04/30/2007 *Fix menu border problem. News In 4.80 04/20/2007 *Fix menu border problem in windows2000. News In 4.76 04/11/...

    PS Tray Factory v3.2 (shareware version)

    - to change the order of icons in the system tray (sort tray), - to restore system tray icons after Explorer.exe crash, - to replace the original tray icons with your own icons, - to quickly ...

    高中英语单词天天记restore素材

    - 例如:"His recent success has helped to restore his faith in his own ability."(他最近的成功帮助他恢复了对自己能力的信心) - restore sb/sth to sb/sth: - 例如:"The court will make every effort to...

    Store/Restore Tabs-crx插件

    语言:English (United States) 此扩展提供了存储和还原选项卡的功能 用户可以在浏览器存储中存储和还原所有选项卡URL。 即使关闭了浏览器,用户也将能够还原选项卡。 您的数据将在所有设备上同步。...

    VB编程资源大全(英文源码 API)

    &lt;END&gt;&lt;br&gt;56,Edge.zip In my program i have used few API functions to set 3D,Sunken,etched effects to the images of your image control.Another example shows how to change your label control to a 3D ...

Global site tag (gtag.js) - Google Analytics