12c ORA-12504: “TNS:listener Was Not Given The service_name In connect_data”

C:\Users\lhongjie>sqlplus sysdg@"192.168.56.101:1526/db12c"  as sysdg
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 7月 7 13:41:53 2018
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
ERROR:
ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME
请输入用户名:

配置tnsnames.ora

db12c =
  (description =
    (address_list =
      (address = (protocol = tcp)(host = 192.168.56.101)(port = 1526))
    )
    (connect_data =
      (service_name = db12c)
    )
  )
C:\Users\lhongjie>sqlplus sysdg@db12c as sysdg
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 7月 7 13:46:14 2018
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
输入口令:
连接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>

经过测试原理是单引号才可以

C:\Users\lhongjie>sqlplus sys@'192.168.56.101:1526/db12c' as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 7月 7 15:19:08 2018
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
输入口令:
上次成功登录时间: 星期六 7月  07 2018 15:18:03 +08:00
连接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
This entry was posted in oracle. Bookmark the permalink.