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

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

作者: jiawang    时间: 2019-8-29 13:52
标题: ORA-12162: TNS:net service name is incorrectly specified 错误解决
报错现象:
[oracle@hisdg ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 29 00:59:02 2019
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@hisdg ~]$ sqlplus system/oracle@orcl
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 29 01:02:23 2019

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


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



SQL>


报错原因:ORACLE_SID没有指定导致的!
[oracle@hisdg ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[oracle@hisdg ~]$ echo $ORACLE_SID


[oracle@hisdg ~]$ ls -al

drwx------  4 oracle oinstall 4096 8月  29 00:58 .
drwxr-xr-x. 4 root   root     4096 8月  20 21:48 ..
-rw-------  1 oracle oinstall  890 8月  29 00:46 .bash_history
-rw-r--r--  1 oracle oinstall   18 8月  29 2012 .bash_logout
-rw-r--r--  1 oracle oinstall  441 8月  29 00:58 .bash_profile
-rw-r--r--  1 oracle oinstall  124 8月  29 2012 .bashrc
drwxr-xr-x  2 oracle oinstall 4096 7月  14 2010 .gnome2
drwxr-xr-x  4 oracle oinstall 4096 8月   9 03:39 .mozilla
-rw-------  1 oracle oinstall  649 8月  29 00:58 .viminfo
[oracle@hisdg ~]$ vi .bash_profile
[oracle@hisdg ~]$  source .bash_profile
[oracle@hisdg ~]$ echo $ORACLE_SID     
orcl

再次尝试登陆:
[oracle@hisdg ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 29 01:04:12 2019
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

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

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DGDATA/orcl/datafile/system.256.1017533309
+DGDATA/orcl/datafile/sysaux.257.1017533309
+DGDATA/orcl/datafile/undotbs1.258.1017533309
+DGDATA/orcl/datafile/users.259.1017533309

SQL>                                                   











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