How to connect SQLPlus with tnsnames.ora
Your command should be:
sqlplus user/password@HOST
with no space between the password and @HOST
part.
With the space it treats the @HOST
as a script to execute once you've logged in, and it tries to connect locally, which produced that TNS error. (As you don't log in the HOST
isn't ever evaluated to establish if it exists, so it's effectively noise at this point).
C:\>sqlplus -l -s x/y @HOST
ERROR:
ORA-12560: TNS:protocol adapter error
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
With the space removed it looks for HOST
as a TNS alias:
C:\>sqlplus -l -s x/y@HOST
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
For me that still gets an error since I don't have HOST
in my tnsnames.ora
, but it's a different error and you can see it's at least trying to use it as a TNS alias. If you have it defined properly it will be able to connect to your database.