重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 318|回复: 0
打印 上一主题 下一主题

[Oracle] Oracle 修改 sys 密码无效,依旧报ORA-01017: invalid username/password; logon d...

[复制链接]
跳转到指定楼层
楼主
发表于 2025-2-27 13:49:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2025-2-27 13:49 编辑

问题现象:
Oracle 数据库,修改了 sys 密码,怎么都无法登录,一直报错:
## 修改 sys 密码成功
SQL> alter user sys identified by oracle;
User altered.

## 登录报错
[oracle@sztech admin]$ sqlplus sys/oracle@sztech as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 5 10:19:22 2025
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
怎么会修改不了 sys 密码呢?


问题分析与解决
检查一下监听,监听状态是正常的:
[oracle@sztech admin]$ lsnrctl stat
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-FEB-2025 09:54:25
opyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                05-FEB-2025 09:54:07
Uptime                    0 days 0 hr. 0 min. 17 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/lucifer/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sztech)(PORT=1521)))
Services Summary...
Service "sztech" has 1 instance(s).
  Instance "lucifer", status READY, has 1 handler(s) for this service...
Service "sztechXDB" has 1 instance(s).
  Instance "sztech", status READY, has 1 handler(s) for this service...
The command completed successfully


检查一下 sqlnet 配置,没问题:
[oracle@sztech admin]$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.


NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)


ADR_BASE = /u01/app/oracle


[oracle@sztech admin]$ tnsping lucifer
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 05-FEB-2025 10:12:46
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/db/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = sztech)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = sztech)))
OK (0 msec)


确定tnsping没问题了,再次尝试下连接 sys 用户:
[oracle@sztech admin]$ sqlplus sys/oracle@sztech as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 5 10:12:59 2025
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied


手动再次修改 sys 密码:
SQL> alter user sys identified by oracle;
User altered.


SQL> alter user system identified by oracle;
User altered.


再次尝试连接:
[oracle@sztech admin]$ sqlplus sys/oracle@sztech as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 5 10:13:25 2025
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied


试一下 system 用户连接:
[oracle@sztech admin]$ sqlplus system/oracle@sztech
SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 5 10:18:53 2025
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>
SQL>
那看来就是 sys 用户本身有问题了,再看一下 sys 用户的状态:


SQL> set lines222 pages1000
col username for a25
col account_status for a20
col default_tablespace for a20
col temporary_tablespace for a20
col profile for a20
SELECT username,
       account_status,
       default_tablespace,
       temporary_tablespace,
       created,
       profile
  FROM dba_users
WHERE account_status = 'OPEN'
ORDER BY created;


USERNAME                  ACCOUNT_STATUS       DEFAULT_TABLESPACE   TEMPORARY_TABLESPACE CREATED            PROFILE
------------------------- -------------------- -------------------- -------------------- ------------------ --------------------
SYSTEM                    OPEN                 SYSTEM               TEMP                 24-AUG-13          DEFAULT
SYS                       OPEN                 SYSTEM               TEMP                 24-AUG-13          DEFAULT

查看密码文件
[oracle@sztech dbs]$ ll
total 16
-rw-rw----  1 oracle oinstall 1544 Jun 29  2023 hc_sztech.dat
-rw-r--r--. 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r-----  1 oracle oinstall   24 Oct 15  2021 lkSZTECH
-rw-r-----  1 oracle oinstall 3584 Jun 29  2023 spfilesztech.ora
好家伙,没有密码文件,好吧,怪不得怎么改都没用,手动新建一个密码文件:


[oracle@sztech dbs]$ orapwd file=orapwsztech password=oracle
再次尝试连接 sys 用户:


[oracle@sztech dbs]$ sqlplus sys/oracle@sztech as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 5 10:23:17 2025


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>
SQL>



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2025-3-12 21:03 , Processed in 0.104339 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表