Oracle 报错:ORA-01017

682 阅读1分钟

这是我参与8月更文挑战的第27天,活动详情查看:8月更文挑战

报错信息

数据库客户端用 sys 用户连接,报错信息如下: image.png

排查,定位报错原因

针对上述报错信息,首先想到了密码错误,登录服务器,免密认证连入数据库手动修改密码:

[oracle@dj ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 27 09:57:39 2021

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.

再次尝试客户端连接,发现仍然报错: image.png 查询口令文件信息,发现无结果返回:

SQL> select * from v$pwfile_users;

no rows selected

因客户端为 sys 用户连接,此时可以定位应该是数据库 sys 用户的口令文件(密码文件)失效了。

解决

重建口令文件:

[oracle@dj ~]$ cd $ORACLE_HOME/dbs
[oracle@dj dbs]$ ll
total 20
-rw-rw---- 1 oracle oinstall 1544 Aug 14 23:06 hc_orcl.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   24 Dec 30  2020 lkORCL
-rw-r----- 1 oracle oinstall 1536 Jun  8 09:44 orapworcl
-rw-r----- 1 oracle oinstall 3584 Aug 26 22:11 spfileorcl.ora
[oracle@dj dbs]$ mv orapworcl orapworcl.bak
[oracle@dj dbs]$ ll
total 20
-rw-rw---- 1 oracle oinstall 1544 Aug 14 23:06 hc_orcl.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   24 Dec 30  2020 lkORCL
-rw-r----- 1 oracle oinstall 1536 Jun  8 09:44 orapworcl.bak
-rw-r----- 1 oracle oinstall 3584 Aug 26 22:11 spfileorcl.ora
[oracle@dj dbs]$ pwd
/msun/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@dj dbs]$ orapwd  file=/msun/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl password=oracle force=y;
[oracle@dj dbs]$ ll
total 24
-rw-rw---- 1 oracle oinstall 1544 Aug 14 23:06 hc_orcl.dat
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   24 Dec 30  2020 lkORCL
-rw-r----- 1 oracle oinstall 1536 Aug 27 10:06 orapworcl
-rw-r----- 1 oracle oinstall 1536 Jun  8 09:44 orapworcl.bak
-rw-r----- 1 oracle oinstall 3584 Aug 26 22:11 spfileorcl.ora

再次在数据库中查看口令文件信息,显示生效中:

SQL> select * from v$pwfile_users;

USERNAME                       SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS                            TRUE  TRUE  FALSE

客户端再次连接,可正常登录:

image.png