I installed Sql*PLUS on a cloud Oracle Linux Environment in order to access an remote database. I used the installation instructions provided as an answer here: https://stackoverflow.com/questions/23488394/how-to-install-sql-plus-client-in-linux
My connection string is correct, but I get the error
ERROR: ORA-12154: TNS:could not resolve the connect identifier specified
I tried resolving this issue by attempting to looking at my tnsnames.ora
, but it did not exist and the path connected to my $ORACLE_HOME
did not have the subfolders "/network/admin/
". In order to resolve this, I created both folders and created a tnsnames.ora
file in the new admin/
containing my connection string. Unfortunately, I still get the same error.
The path to my new tnsnames.ora
file being:
/usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
For reference my connection string is structured the following way:
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST= asdasdasd.com)(PORT=1524))
(CONNECT_DATA =
(SID = AARCER1)
)
)
And my command I am putting into my terminal is:
sqlplus "userName/myPassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=asdasdasd.com)(PORT=1524))(CONNECT_DATA=(SID=AARCER1)))"
What should I do to resolve this error?
Best Answer
When you use
sqlplus userName/myPassword@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=asdasdasd.com)(PORT=1524))(CONNECT_DATA=(SID=AARCER1)))"
then you don't need anytnsnames.ora
file.Your entry in
tnsnames.ora
file should be like this:Then you can shorten your command to
sqlplus userName/myPassword@AARCER1
- that is the purpose oftnsnames.ora
.In order to use
tnsnames.ora
you must also have filesqlnet.ora
. There you need an entry like this:However, default value is
NAMES.DIRECTORY_PATH=(tnsnames, ldap, ezconnect)
, so actually you can skip it.Set environment variable
TNS_ADMIN
to location of these files, i.e.