|
本帖最后由 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>
|
|