oracle ORA-12545:连接失败,因为 Mac 中不存在目标主机或对象 - SQLPLUS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45396532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-12545: Connect failed because target host or object does not exist in Mac - SQLPLUS
提问by n92
I have installed sqlplus instantclient in Mac OS X EI Captain.
我已经在 Mac OS X EI 船长中安装了 sqlplus Instantclient。
I am able to connect to database by typing the below command in terminal
我可以通过在终端中键入以下命令来连接到数据库
sqlplus uname/pwd@//localhost:1521/myDB
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.
我需要在没有完整连接字符串的情况下连接到数据库,我只需要输入sqlplus
然后输入用户名和密码,这会引发以下错误。
ERROR:
ORA-12545: Connect failed because target host or object does not exist
I have below environment variables set and tnsnames.ora is created.
我设置了以下环境变量并创建了 tnsnames.ora。
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.
下面是 ~/etc 位置下的 tnsnames.ora。
myDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost) (PORT = 1521))
(
CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = myDB)
)
)
回答by William Robertson
Set the TWO_TASK
environment variableto define the default connect string, e.g.
设置TWO_TASK
环境变量以定义默认连接字符串,例如
export TWO_TASK=${ORACLE_SID}
Also test the configuration with tnsping myDB
.
还测试配置tnsping myDB
。