Oracle的sqlnet.ora与password文件试验

先看有没有sqlnet.ora

[oracle@localhost ~]$ cd $ORACLE_HOME
[oracle@localhost dbhome_1]$ cd network
[oracle@localhost network]$ cd admin
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst
[oracle@localhost admin]$

手动创建一个sqlnet.ora文件

[oracle@localhost admin]$ touch sqlnet.ora
[oracle@localhost admin]$ vim sqlnet.ora
[oracle@localhost admin]$ cat sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES=(none);
[oracle@localhost admin]$

试验登陆情况:

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:26:25 2014

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

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:

*********************************

查看口令文件情况:

[oracle@localhost dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@localhost dbs]$ ls
hc_orcl.dat  init.ora  initorcl.ora  lkORCL  orapworcl  spfileorcl.ora
[oracle@localhost dbs]$

现在执行口令文件处理:

用老的口令文件改口令不被允许:

[oracle@localhost dbs]$ orapwd file=orapworcl password=gaojian

OPW-00005: File with same name exists - please delete or renam

只好再作一个新的:

[oracle@localhost dbs]$ orapwd file=orapwgaojian password=gaojian
[oracle@localhost dbs]$ ls
hc_orcl.dat  initorcl.ora  orapwgaojian  spfileorcl.ora
init.ora     lkORCL        orapworcl
[oracle@localhost dbs]$

用刚刚作好的口令,还是不行(因为它和oracle中的sys口令不一致,是我随便设的,所以不行,其实登陆到哪个实例,就会用哪个口令文件--orapw<SID>):

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:32:23 2014

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

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys as sysdba
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost admin]$

*******************************

考虑删除orapworcl (这个操作实际上有一定的危险性):

[oracle@localhost dbs]$ rm orapworcl
[oracle@localhost dbs]$

一样也是登陆不进去:

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:34:24 2014

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

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys as sysdba
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost admin]$

*******************************

把sqlnet.ora中的 SQLNET.AUTHENTICATION_SERVICES=(none); 注释掉,再试验:

[oracle@localhost admin]$ cat sqlnet.ora
#SQLNET.AUTHENTICATION_SERVICES=(none);
[oracle@localhost admin]$

[oracle@localhost dbs]$ strings orapwgaojian
][Z
ORACLE Remote Password file
INTERNAL
FE406C76B620912C
861BAF16E111B672
[oracle@localhost dbs]$

登陆到数据库中,来更改口令:

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:44:08 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter user sys identified by oracle;

User altered.

SQL>exit

[oracle@localhost dbs]$ strings orapwgaojian
][Z
ORACLE Remote Password file
INTERNAL
FE406C76B620912C
861BAF16E111B672
[oracle@localhost dbs]$

口令文件似乎无变化。

还是登陆不进去:

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:45:41 2014

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

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys as sysdba
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:

*******************************

看来还得用orapw<SID>的文件来对应。

[oracle@localhost dbs]$ orapwd file=orapworcl

Enter password for SYS:
[oracle@localhost dbs]$
输入的口令是刚才在数据库中设置的口令。

然后,再登陆看看:

此时,可以登陆成功了:

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 15 08:47:58 2014

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

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys as sysdba
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

原文地址:https://www.cnblogs.com/gaojian/p/3665412.html