关闭

oracle无法解析指定的连接标识符

标签: oracle数据库serverlisttcpnetwork
15700人阅读 评论(1) 收藏 举报

oracle数据库安装在其他电脑上,自己的电脑上安装oracle客户端,这时下面的

代码可以连上数据库,把数据导出来。

echo 导出数据库数据
set user=username
exp %user%/password@abc file=E:/数据库备份/%user%-%date%.db

但是如果再在本机上安装服务器端,发现下面错误(ORA-12154:TNS:无法解析指定的连接标示符)。

image

解决方法是,打开client安装目录下network->admin下的tnsnames.ora文件

内容如下:

# tnsnames.ora Network Configuration File: F:/oracle/product/10.2.0/client_2/NETWORK/ADMIN/tnsnames.ora
# Generated by Oracle configuration tools.

abc =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.9)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = orcl)
      (SERVER = DEDICATED)
    )
  )

127.0.0.1_LOCALLOST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = Locallost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = 127.0.0.1)
      (SERVER = DEDICATED)
    )
  )

ORCL_LOCALHOST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = Localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = orcl)
      (SERVER = DEDICATED)
    )
  )

把红色字体部分,拷贝到服务器端的安装目录下network->admin下的tnsnames.ora文件。如下所示:

# tnsnames.ora Network Configuration File: F:/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 74B5853F2D1648B)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

abc =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.9)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = orcl)
      (SERVER = DEDICATED)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )

修改后,发现可以连接数据库了。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:43643次
    • 积分:601
    • 等级:
    • 排名:千里之外
    • 原创:18篇
    • 转载:5篇
    • 译文:0篇
    • 评论:3条
    文章分类