很可能 Oracle 服务尚未启动。打开 powershell 并使用
检查它get-service OracleService*
如果它说已停止,那么你可以做
get-service OracleService* | start-service
如果它已启动,则您的
oracle_sid
环境变量尚未设置,或者您的 oracle_home
不正确。
不幸的是,我看不到您在哪里显示了实际的 sqlplus 命令,只是一个屏幕截图,显示了 after sqlplus 获得控制权。但我发现几乎 100% 的情况下我都会看到这个错误,这是因为 sqlplus 启动时没有指定连接描述符。这样做意味着您正在请求“本地”连接,因此侦听器或任何其他 TNS 组件根本不涉及。相反,sqlplus 尝试与环境变量 ORACLE_SID 指定的运行实例建立本地(在内存中)连接:
TNS 连接:
G:\scripts>sqlplus scott/tiger@edstest
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:46:01 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Tue Oct 27 2020 15:45:42 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
SQL>
本地连接,先检查ORACLE_SID
G:\scripts>echo %ORACLE_SID%
edstest
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:47:32 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Tue Oct 27 2020 15:46:01 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
SQL>
未设置 ORACLE_SID 的本地连接,或设置不正确:
G:\scripts>set ORACLE_SID=FUBAR
G:\scripts>echo %ORACLE_SID%
FUBAR
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:48:57 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name: ^C
G:\scripts>set ORACLE_SID=
G:\scripts>echo %ORACLE_SID%
%ORACLE_SID%
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:49:59 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
这就是你的错误。