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

    技术2022-08-01  85

    原文地址::https://blog.csdn.net/sunansheng/article/details/50209557?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

    相关文章

    1、Oracle案例05——ORA-12162: TNS:net service name is incorrectly specified----https://www.cnblogs.com/rangle/p/8926414.html

    2、ORACLE 12C ORA-12162: TNS:net service name is incorrectly specified 错误解决----https://blog.csdn.net/fw19940314/article/details/80432997

    3、linux下导出oracle时报错【ORA-12154: TNS:could not resolve the connect identifier specified】----https://blog.csdn.net/jaejoong/article/details/46743689

     

    本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-12162错误的案例。希望大家有所思考。

    1.故障现象 本文所要描述的故障与这个通用的问题描述不同,在数据库服务器端使用TNSNAMES.ORA中记录的连接串连接没有问题,但如若未指定连接串,将会报出ORA-12162错误。

    1)使用system用户尝试登录系统,此时便会收到报错如下信息 [oracle@asdlabdb01 ~]$ sqlplus system/sys   SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:02 2010 Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.   ERROR: ORA-12162: TNS:net service name is incorrectly specified   Enter user-name: 2)使用sysdba身份登陆会得到同样的错误信息 [oracle@asdlabdb01 ~]$ sqlplus / as sysdba   SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:48 2010   Copyright (c) 1982, 2006, Oracle.  All Rights Reserved. ERROR: ORA-12162: TNS:net service name is incorrectly specified   Enter user-name: 3)但此时,如果使用服务名方式连接数据库,是可以成功的,这也是该问题现象的诡异之处。 [oracle@asdlabdb01 ~]$ sqlplus system/sys@ora10g   SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:53:41 2010   Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.   Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options   system@ora10g>

    想象一下,你的目标是快速的进入到数据库中进行维护操作,但此时登录都遭遇障碍,会感到非常的别扭。更让人抓狂的是,如果此时使用连接串登录到数据库进行停起操作,结果将会处于更加惨烈境况:数据库将因为无法正常登录导致无法启动数据库。

    2.故障原因 诡异的故障背后的原因竟然是那样的基础:ORACLE_SID没有指定! 确认系统当前的ORACLE_HOME和ORACLE_SID环境变量 [oracle@asdlabdb01 ~]$ echo $ORACLE_HOME /oracle/app/oracle/product/10.2.0/db_1 [oracle@asdlabdb01 ~]$ echo $ORACLE_SID   [oracle@asdlabdb01 ~]$

    可见,此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。

    3.故障处理 给出ORACLE_SID,重新尝试登录。 [oracle@asdlabdb01 ~]$ export ORACLE_SID=ora10g [oracle@asdlabdb01 ~]$ echo $ORACLE_SID ora10g [oracle@asdlabdb01 ~]$ sqlplus / as sysdba   SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 23:27:34 2010   Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.   Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options   sys@ora10g>

    OK,此时问题处理完毕。

    ———————————————— 版权声明:本文为博主「sunansheng」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/sunansheng/article/details/50209557

    Processed: 0.010, SQL: 9