ORA-01017

ORA-01017

1 错误信息

不管是在sqlplus 命令下,还是在程序连接都有可能会遇到这个问题, 特别是在数据库升级后, 或者是老程序连接新安装的Oracle12C 及以后版本的数据库。基本都会遇到这个问题。

ORA-01017:invalid username/password; logon denied

2 分析

 

2.1 sqlplus环境登录

oracle 12C 以后,数据库分为container 和 pdb 两个层面。在Container 里建用户与pdb 中建用户有所区别。 在Container 中建用户,需要以 'C##' 开头。如下:

SQL> create user test identified by test;
create user test identified by test
            *
ERROR at line 1:
ORA-65096: invalid common user or role name


SQL> create user C##test identified by test;

User created.

而在pdb 中建用户则不需要:

SQL> alter session set container=amscenter;

Session altered.

SQL> create user test identified by test;

User created.

对于这种,我们首先要确认的是,我们想要登录的是cdb,还是pdb。

  • 登录cdb

    登录cdb,则在用户名前加上 C##:

    SQL> grant connect,resource to c##test;
    
    Grant succeeded.
    
    SQL> conn c##test/test;
    Connected.
    
  • 登录pdb

    登录pdb,有两种方法,一种是使用tnsname,一种是先把当前环境切换到 pdb :

    -- 通过tns 可以正常登录
    SQL> conn scott/tiger@pdbboss
    Connected.
    -- 或者
    sqlplus test/test@amscenter
    

2.2 密码加密解析错误

Oracle 的密码加密方式,在不同的数据库版本中,是不尽相同的。 12C 以后的加密方式,无法识别过低版本驱动提供的加密后的密码。

针对这种情况,需要在数据库层面做如下操作:

  • 第一步:修改sqlnet.ora,加入以下两个参数:

    SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
    SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
    
    - 第二步:修改用户密码,生成支持低版本密码加密格式。
      #+BEGIN_EXAMPLE
    alter user &username identified by &password;
    

Author: halberd.lee

Created: 2020-08-14 Fri 14:18

Validate

posted @ 2020-06-10 17:34  halberd.lee  阅读(1216)  评论(0编辑  收藏  举报