Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
        )
)
like image 605
n92 Avatar asked Oct 16 '25 22:10

n92


1 Answers

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.

like image 196
William Robertson Avatar answered Oct 18 '25 14:10

William Robertson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!