connecting to remote oracle via cygwin sqlplus
Question
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 username@myserver.mycompany.com: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?
Solution
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.
OTHER TIPS
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.
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
:
export ORACLE_HOME=c:\\Oracle\\product\\12.1.0\\dbhome_1
export TNS_ADMIN=d:\\Oracle\TNSAdmin
export PATH=$PATH:$(cygpath -u $ORACLE_HOME)/BIN
After that, I had no more issues calling e.g. tnsping
or sqlplus
. As the above is just an example, you must of course adjust the paths to reflect your installation/configuration :)
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
and ORACLE_SID
and was then able to run sqlplus in a cygwin bash shell using the net_service_name
from tnsnames.ora.
The way it worked for me was to remove /cygdrive/d
or /cygdrive/c
and replace them with with d:/
or c:/
and then your sqlplus
call within cygwin session will work. The /cygdrive/DriveLetter
is confusing it.
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