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

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1340|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2018-1-18 15:33:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 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



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-27 01:05 , Processed in 0.076361 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表