我是这么做的
1,安装odbc驱动,然后配置连接,连接名:mysqllink
2,在oralcehome 下 新建 initmysql.ora文件
内容为:
#这里指定odbc的名称
HS_FDS_CONNECT_INFO = mysqllink
#指定追逐级别,一般设成OFF,为了方便调试这里设成debug,在%ORACLE_HOME%/hs/trace下查看追逐文件信息
HS_FDS_TRACE_LEVEL = debug
3,配置listener.ora
(SID_DESC =
(SID_NAME = mysql)
(ORACLE_HOME =D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = dg4odbc)
)
重启监听服务。
4,配置tnsnames.ora
增加:
MYSQL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.35.130)(PORT= 1521))
)
(CONNECT_DATA =
(SID = mysql)
)
(HS=OK)
)
然后创建create database link mysqllink connect to "root" identified by "mysql"using 'MYSQL';
接着访问mysql数据库的db表
select * from "db"@mysqllink ;报错ORA-12154: TNS: 无法解析指定的连接标识符
改成:select * from root.db@mysqllink; 报同样的错
换种创建dblink方式:
create database link dblinktest4 connect to "opt4" identified by "mysql" using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = DELL-PC)(PORT= 1521))
)
(CONNECT_DATA =
(SID = mysql)
)
(HS=OK)
)';
然后再select * from opt4.db@dblinktest4;此时报错为:
ORA-28545: 连接代理时 Net8 诊断到错误
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: 紧接着 2 lines (起自 DBLINKTEST3)
不是太明白,要怎么解决
------解决思路----------------------
你的数据库是名字叫MYSQL,还是数据库软件是MYSQL?