Reputation: 7602
I have installed sqlplus instantclient in Mac OS X EI Captain.
I am able to connect to database by typing the below command in terminal
sqlplus uname/pwd@//localhost:1521/myDB
I need to connect to database without full connection string, Just i need to type sqlplus
then i enter username and password, this is throwing below error.
ERROR:
ORA-12545: Connect failed because target host or object does not exist
I have below environment variables set and tnsnames.ora is created.
export ORACLE_HOME=/opt/oracle/instantclient
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
export NLS_LANG=AMERICAN_AMERICA.UTF8
export TNS_ADMIN=~/etc
export PATH=$PATH:$ORACLE_HOME
export ORACLE_SID=myDB
I am not sure why i am getting this error.
Below is the tnsnames.ora under ~/etc location.
myDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost) (PORT = 1521))
(
CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = myDB)
)
)
Upvotes: 4
Views: 38747
Reputation: 16001
Set the TWO_TASK
environment variable to define the default connect string, e.g.
export TWO_TASK=${ORACLE_SID}
Also test the configuration with tnsping myDB
.
Upvotes: 4