ORA-12162: TNS:net service name is incorrectly specified

  今天使用oracle用户登录sqlplus出现“ORA-12162: TNS:net service name is incorrectly specified”。
    如下:
[oracle@oracle ~]$ sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 29 19:19:26 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Enter user-name: sys
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
 
    网上查询是没有设置ORACLE_SID环境变量原因。
    1、查看是否设置环境变量,用“echo  $ORACLE_SID”查询,如下:
[oracle@oracle ~]$ echo $ORACLE_SID
 
[oracle@oracle ~]$
    2、设置环境变量,用"vi .bash_profile"编辑命令,在其后加 "export  ORACLE_SID=oracle13g"。
    3、使用“source .bash_profile”命令,使环境变量生效。
    4、再使用oracle用户登录sqlplus,成功。如下:
[oracle@oracle ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 29 19:41:43 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
 
 下面是从网上转载过来的,见 http://space.itpub.net/519536/viewspace-672034
 
使用命令oerr ora 12162查询,如下:
[oracle@oracle ~]$ oerr ora 12162
12162, 00000, "TNS:net service name is incorrectly specified"
// *Cause:  The connect descriptor corresponding to the net service name in
// TNSNAMES.ORA or in the directory server (Oracle Internet Directory) is
// incorrectly specified.
// *Action: If using local naming make sure there are no syntax errors in
// the corresponding connect descriptor in the TNSNAMES.ORA file. If using
// directory naming check the information provided through the administration
// used for directory naming.

你可能感兴趣的:(ORA-12162: TNS:net service name is incorrectly specified)