Ora-12545: Connect Failed Because Target Host or Object Does Not Exist in Mac - Sqlplus

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)
        )
)
3

1 Answer

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest