通过cygwin sqlplus连接到远程oracle
我正在尝试使用 cygwin sqlplus 连接到位于 myserver.mycompany.com 端口 1530 的远程 Oracle 安装。当我尝试时,
sqlplus [email protected]:1530/orcl
出现错误:
ORA-12154: TNS:could not resolve the connect identifier specified
当我将 ORACLE_HOME
设置为 /cygdrive /c/oracle/product/10.2.0/client_1
,我得到一个不同的错误:
Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
我可以telnet到服务器的1530端口,并且本地安装的SQL Developer也能够连接到数据库。 我究竟做错了什么?
I'm trying to use cygwin sqlplus to connect to a remote oracle installation located at myserver.mycompany.com port 1530. When I try
sqlplus [email protected]:1530/orcl
I get the error:
ORA-12154: TNS:could not resolve the connect identifier specified
When I set ORACLE_HOME
to /cygdrive/c/oracle/product/10.2.0/client_1
, I get a different error:
Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
I can telnet to the server's port 1530, and the SQL Developer installed locally is also able to connect to the database. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我和你有同样的错误,
你不仅应该在windows变量中设置
ORACLE_HOME
,而且还要
PATH
包含%ORACLE_HOME%\ bin
然后你可以打开windows cmd,
尝试
sqlplus username/password@your_define_tnsname
如果可以,然后删除cygwin中所有
ORACLE PATH
设置,重新启动cygwin,尝试一下。如果失败,首先应该让sqlplus在windows cmd中正常运行
I have same error like you,
you should set not only
ORACLE_HOME
in windows Variables,But also
PATH
include%ORACLE_HOME%\bin
then you can open windows cmd,
try
sqlplus username/password@your_define_tnsname
if okay, then remove all
ORACLE PATH
setting in cygwin, restart cygwin,try it.if failure, should let sqlplus works well in windows cmd at first
我配置了 TNS_ADMIN 变量,它在 Win 环境中正常工作
我在 .bashrc 中使用了 cygpath mnodification
如果配置了 TNS_ADMIN,请将以下行添加到 .bashrc
I have TNS_ADMIN variable configured and it works properly in Win Environ
I used cygpath mnodification in .bashrc
If TNS_ADMIN is configured add following row to .bashrc
我不知道 Oracle 有一个原生的 cygwin 客户端(如果我错了,请纠正我,但我在 Oracle 的网站上也找不到任何提及它的信息)。 如果您将 Cygwin 与 Windows 客户端一起使用,则需要使用本机 Windows 路径。 它不会理解您的 /cygdrive 路径。
不过,我已经将 Win32 Oracle 客户端与 cygwin 一起使用并使其工作 - 相同的 shell 脚本可以在 Cygwin、Linux 和 Solaris 上工作。
I wasn't aware there was a native cygwin client for Oracle (correct me if I'm wrong here but I can't find any mention of it on Oracle's web site either). If you're using Cygwin with the Windows client you need to use a native windows path. It won't understand your /cygdrive path.
However, I have used Win32 Oracle clients with cygwin and made it work - the same shell scripts would work on Cygwin, Linux and Solaris.
没有 cygwin Oracle 客户端。 如上面的答案,使用 ORACLE_HOME 设置为 windows 路径。
对于问题的前半部分,请尝试查看 TNS_NAMES 环境变量的设置,如果未设置,您可能需要尝试将其设置到正确的位置。 通常它默认为 %ORACLE_HOME%/network/admin/tnsnames.ora 。 SQL Developer 保留它自己的 tnsnames 文件副本,因此您无法回复该文件来解决问题。
There isn't a cygwin Oracle client. As above answer, use the ORACLE_HOME set to the windows path.
For the first half of your question, try seeing what the TNS_NAMES env variable is set to, and if not set, you may need to try setting it to the correct place. Usually it defaults to %ORACLE_HOME%/network/admin/tnsnames.ora . SQL Developer keeps it's own copy of the tnsnames file, so you can't reply upon that to fix the problem.
结合其他答案的详细信息(这花了我一点时间,所以我将其作为单独的答案而不是评论发布):
$ORACLE_SID
以及,如果设置的话,$TNS_ADMIN
(可能还有其他与路径相关的 Oracle 变量)必须使用 Windows 路径。 您的 Cygwin$PATH
变量当然应该使用 Cygwin 表示法 (/drives/c/...
)。 因此,我已将其包含到我的.bashrc
中:此后,我在调用
tnsping
或sqlplus
时不再遇到问题。 由于上面只是一个示例,您当然必须调整路径以反映您的安装/配置:)Combining the details from the other answers (which took me a little, so I post it as separate answer instead of comments):
The
$ORACLE_SID
and, if set,$TNS_ADMIN
(and probably other path-related Oracle variables) must use Windows-paths. Your Cygwin$PATH
variable should of course use the Cygwin notation (/drives/c/…
). So I've included into my.bashrc
:After that, I had no more issues calling e.g.
tnsping
orsqlplus
. As the above is just an example, you must of course adjust the paths to reflect your installation/configuration :)NXC 是对的——我使用的不是 cygwin 客户端,而是 windows sqlplus 客户端。
我为
ORACLE_HOME
和ORACLE_SID
设置了 Windows 环境变量,然后能够使用 tnsnames.ora 中的net_service_name
在 cygwin bash shell 中运行 sqlplus 。NXC is right - it wasn't a cygwin client I was using, but the windows sqlplus client.
I set the windows environment variables for
ORACLE_HOME
andORACLE_SID
and was then able to run sqlplus in a cygwin bash shell using thenet_service_name
from tnsnames.ora.它对我有用的方法是删除
/cygdrive/d
或/cygdrive/c
并将其替换为d:/
或>c:/
然后您在 cygwin 会话中的sqlplus
调用将起作用。/cygdrive/DriveLetter
令人困惑。The way it worked for me was to remove
/cygdrive/d
or/cygdrive/c
and replace them with withd:/
orc:/
and then yoursqlplus
call within cygwin session will work. The/cygdrive/DriveLetter
is confusing it.