TNSPING OK但sqlplus给ORA-12154?

gla*_*con 13 oracle sqlplus oracle11g ora-12514

我在Windows服务器上运行了Oracle 11,并且我登录到尝试使用SQL Plus的同一服务器上.当我尝试连接时,即使TNSPING和其他各种诊断看起来没问题,我也会得到ORA-12154.

谁有人建议为什么?下面的大量详细信息.


如果我像这样使用EZCONNECT,我可以使用sqlplus ..

sqlplus EST/EST@192.168.10.15/ORCL
Run Code Online (Sandbox Code Playgroud)

...但是如果我尝试使用这样的TNSNAMES进行连接......

sqlplus EST/EST@ORCL
Run Code Online (Sandbox Code Playgroud)

......我明白了......

ORA-12154: TNS:could not resolve the connect identifier specified
Run Code Online (Sandbox Code Playgroud)

TNSPING工作正常

C:\Documents and Settings\user1>tnsping ORCL

TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 12-NOV-2013 12:41:14

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
E:\app\Administrator\product\11.2.0\dbhome_2\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.15)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL))
)
OK (20 msec)
Run Code Online (Sandbox Code Playgroud)

听者看起来是这样的:

C:\Documents and Settings\user1>lsnrctl services

LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 14-NOV-2013 12:02:59

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:55 refused:0 state:ready
         LOCAL SERVER
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: MARIEL, pid: 2400>
         (ADDRESS=(PROTOCOL=tcp)(HOST=mariel)(PORT=1045))
The command completed successfully
Run Code Online (Sandbox Code Playgroud)

还有这个

C:\Documents and Settings\user1>lsnrctl status

LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 14-NOV-2013 12:29:21

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date                14-NOV-2013 11:41:10
Uptime                    0 days 0 hr. 48 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   E:\app\Administrator\product\11.2.0\dbhome_2\network\admin\listener.ora
Listener Log File         e:\app\administrator\diag\tnslsnr\mariel\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.10.15)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
Run Code Online (Sandbox Code Playgroud)

以下是各种配置文件:

listener.ora中

# listener.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_2\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_2)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:E:\app\Administrator\product\11.2.0\dbhome_2\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.15)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = E:\app\Administrator
Run Code Online (Sandbox Code Playgroud)

tnsnames.ora中

# tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_2\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.15)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  )
Run Code Online (Sandbox Code Playgroud)

SQLNET.ORA

# sqlnet.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_2\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to 
# install "Software Only", this file wont exist and without the native 
# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Run Code Online (Sandbox Code Playgroud)

DCo*_*kie 14

创建一个环境变量TNS_ADMIN,指向tnsnames.ora文件所在的目录.然后尝试连接sqlplus.

如果可行,那么我猜你也可能安装了Oracle客户端软件,当你运行sqlplus时,它会在你的客户端主页中查找tnsnames.ora文件.

- 在窗口中添加环境变量TNS_ADMIN的说明
1.转到控制面板/系统
2.选择高级系统设置
3.选择"高级"选项卡,环境变量按钮位于底部.
4.创建新变量TNS_ADMIN并给出存储.ora文件的路径.例如C:\ app\oracle\product\11.2.0\client_1 \network\admin

  • 谢谢。这有效。我仍然无法理解 tnsping 如何找到 tnsnames.ora 就好,但是 sqlplus 需要环境变量的帮助?! (2认同)

小智 9

如果你的密码中有一个at符号(@),Sqlplus会给出这个错误.Sqlplus认为您正在输入连接字符串作为参数.更改密码(您可以使用SQL Developer执行此操作).

道德:不要在Oracle密码中使用at-signs.