ORA-12162: TNS:net service name is incorrectly specified问题
现象:
目前连接数据库时候出现问题了:
[oracle@as3]$ sqlplus “/ as sysdba”
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name: oral
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name: oral
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
可能问题:
1:~.bash_profile文件中估计没有正确设置ORACLE_SID环境变量
2:检查sqlnet.ora中sqlnet.authentication_services设置
3:用 orapwd 重建密码文件
解决问题:
上面的问题经过检查是由于ORACLE_SID设置引起的,主要是因为在oracle环境变量中,虽然设置了ORACLE_SID,但是没有export引起的。最后在~.bash_profile中设置
export ORACLE_SID,问题解决!
下面是metalink.的解释:
The information in this document.nbspapplies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.3 to 10.1.0.3
This problem can occur on any platform.
Affects most UNIX platforms (not seen on Microsoft Windows due to difference in BEQ communication specifics)
Errors
ORA-12162 "TNS:service name is incorrectly specified"
Symptoms
When trying to connect locally (BEQ) to the database, getting "ORA-12162 error tns:net Service name
is incorrectly spelled"
This is unusual because a TNS:Net service name is not being specified, nor is the environement variable TWO_TASK set.
Cause
The user environment variable $ORACLE_SID is not set.
When this is not set, then SQL*Plus use, without a connect string, may result in an ORA-12162 error.
Solution
Add the ORACLE_SID to the .profile for the Oracle user.
This will give the BEQ adapter a route to connect to the instance.
References
原文地址:
我的情况是:
sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 23 03:05:42 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
参考上文,经过检查:
监听没有起来,Oracle的所有进程都没有起来。即
ps -ef|grep ora_|grep -v grep是空!
第一步:1)cd $ORACLE_HOME/bin
2)lsnrctl start把监听起来
.......
The command completed successfully!
第二步:1)cd $ORACLE_HOME/dbs
2)先删除口令文件:rm orapwcuug
3)然后使用命令:orapwd file=orapwcuug password=oracle entries=3重新建立口令文件
4)最后查看pfile文件initcuug.ora的完整,没有问题!
第三步:1)export ORACLE_SID=cuug
2)echo $ORACLE_SID看结果是否是cuug
第四步:sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 23 03:17:17 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL>startup
ORACLE instance started.
Total System Global Area 419430400 bytes
Fixed Size 1219760 bytes
Variable Size 58721104 bytes
Database Buffers 356515840 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL>
成功!