重庆思庄Oracle、Redhat认证学习论坛

标题: ORA-12162:TNS:net service name is incorrectly specified错误 [打印本页]

作者: jiawang    时间: 2018-1-18 15:33
标题: ORA-12162:TNS:net service name is incorrectly specified错误
本帖最后由 jiawang 于 2018-1-18 15:40 编辑

今天使用oracle用户登录sqlplus出现“ORA-12162: TNS:net service name is incorrectly specified”。
[oracle@strong ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 18 15:08:19 2018
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified


网上查询是没有设置ORACLE_SID环境变量原因。


验证ORACLE_SID环境变量(为空)
[oracle@strong ~]$ echo $ORACLE_SID



但是我明明在环境变量中设置了ORACLE_SID
[oracle@strong ~]$ ls -la
总用量 36
drwx------. 4 oracle dba  4096 6月  28 2017 .
drwxr-xr-x. 3 root   root 4096 6月  28 2017 ..
-rw-------. 1 oracle dba   919 10月 21 10:41 .bash_history
-rw-r--r--. 1 oracle dba    18 8月  29 2012 .bash_logout
-rw-r--r--. 1 oracle dba   441 6月  28 2017 .bash_profile
-rw-r--r--. 1 oracle dba   124 8月  29 2012 .bashrc
drwxr-xr-x. 2 oracle dba  4096 7月  14 2010 .gnome2
drwxr-xr-x. 4 oracle dba  4096 6月  28 2017 .mozilla
-rw-------. 1 oracle dba   649 6月  28 2017 .viminfo
[oracle@strong ~]$ cat ~./bash_profile
cat: ~./bash_profile: 没有那个文件或目录
[oracle@strong ~]$ cat ~/.bash_profile
# .bash_profile


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=YADATA
export ORACLE_UNQNAME=YADATA
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LOIBRARY_PATH=$ORACLE_HOME/lib:
export CVUQDISK_GRP=dba

export PATH
[oracle@strong ~]$
手动设置oralce_sid
[oracle@strong ~]$ export ORACLE_SID=YADATA   
[oracle@strong ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 18 15:18:13 2018
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>


验证数据库状态:
SQL> select status,instance_name from v$instance;  
STATUS       INSTANCE_NAME
------------ ----------------
OPEN         YADATA








欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2