首页 > 解决方案 > 如何使用 SQLPLUS 连接到 Oracle | Oracle 即时客户端 | ORA-12545

问题描述

使用 SQL Developer 成功连接,但是当我在 Oracle Instant Client 中使用 sqlplus 时出现以下问题

方法一:

[integrator@a-esb-app01 instantclient_19_8]$ ./sqlplus EGOINT@139.138.267.202:1521:EPROD

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Dec 22 18:14:36 2020
Version 19.8.0.0.0

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

Enter password:
ERROR:
ORA-12545: Connect failed because target host or object does not exist


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

方法二:

[integrator@a-esb-app01 instantclient_19_8]$ ./sqlplus EGOINT@139.138.267.202:1521/EPROD

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Dec 22 18:18:13 2020
Version 19.8.0.0.0

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

Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

不确定以上哪一个是正确的方法,连接字符串有什么问题或服务器端需要进行任何更改?

注意:我能够成功连接另一个 Oracle 服务器。所以 InstantClient 没有问题

标签: oraclesqlplus

解决方案


使用以下固定:

./sqlplus egoint/egoint@(description=(address=(protocol=tcp)(host=139.138.267.202)(port=1521))(connect_data=(sid=EPROD)))

推荐阅读