一、环境
OS:Linux myhostname 2.6.9-42.ELsmp #1 SMP Sat Aug 12 09:39:11 CDT 2006 i686 i686 i386 GNU/Linux
CentOS release 4.4 (Final)
Oracle:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod,数据库已经安装好
mysql:5.1.34-community for windows
二、安装配置
1. 安装unixODBC,用root用户
rpm -Uvh unixODBC-2.2.12-1.el4s1.1.i386.rpm
2. 安装mysql ODBC,用root用户
rpm -Uvh mysql-connector-odbc-5.1.5-0.i386.rpm
3. 安装oracle gateway,用oracle用户
我装的是10201_gateways_linux32.zip
unzip 10201_gateways_linux32.zip
cd gateways
./runInstaller
安装方法和oracle db 软件一样,我把gateway和db装一起了,共用一个OracleHOME
4. 配置/etc/odbc.ini
[DSName]
Driver =/usr/lib/libmyodbc5.so
Description =MySQL
Server =xxx.xxx.xxx.xxx
Port =3306
User =root
UID =root
Password = mypass
Database =mysqldbname
Option =3
Socket =
charset =utf8
测试ODBC
isql -v DSName root mypass
5. 配置$ORACLE_HOME/hs/admin/initDSName.ora
HS_FDS_CONNECT_INFO = DSName
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME = /usr/lib/libmyodbc5.so
6. 配置listener.ora,加红色部分
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = BOSS)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = BOSS)
)
(SID_DESC =
(SID_NAME = phpcms)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = hsodbc)
)
)
7. 配置tnsnames.ora,添加
DSName =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.125)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = DSName))
(HS = OK)
)
8. 重启监听器并测试
lsnrctl reload
lsnrctl service
Service "DSName" has 1 instance(s).
Instance "DSName", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:3 refused:0
LOCAL SERVER
The command completed successfully
tnsping DSName
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.125)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DSName)) (HS = OK))
OK (0 msec)
9. 建立dblink
CREATE PUBLIC DATABASE LINK linkname
CONNECT TO "root"
IDENTIFIED BY <PWD>
USING 'DSName';
10. 测试
select "name" from t1@linkname;
三、遗留问题
1. 字符集问题,最好oracle和mysql是utf8,否则中文有问题
2. text字段会报错:
select "textcol" from t1@linkname;
ORA-28500: 连接 ORACLE 到非 Oracle 系统时返回此信息:
[Generic Connectivity Using ODBC][MySQL][ODBC 5.1 Driver][mysqld-5.1.34-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"t1" WHERE "id"=1' at line 1 (SQL State: 37000; SQL Code: 1064)
ORA-02063: 紧接着 2 lines (起自 DSName)
本来想用datadirect的mysql ODBC试试,可只支持mysql enterprise版本,实在不好找,以后有机会再说吧。
通过HSODBC访问mysql的实现步骤
2019-11-01 14:48mysql教程网 Mysql
通过HSODBC访问mysql的实现方法,需要的朋友可以参考下。
延伸 · 阅读
- 2022-03-11MySQL的索引你了解吗
- 2022-03-10面试中老生常谈的MySQL问答集锦夯实基础
- 2022-03-10浅谈如何保证Mysql主从一致
- 2022-03-10Ubuntu18.04(linux)安装MySQL的方法步骤
- 2022-03-09MySQL让人又爱又恨的多表查询
- 2022-03-09MySQL Server 层和存储引擎层是怎么交互数据的?
- Mysql
MySQL数据库varchar的限制规则说明
本文我们主要介绍了MySQL数据库中varchar的限制规则,并以一个实际的例子对限制规则进行了说明,希望能够对您有所帮助。 ...
- Mysql
浅谈mysql 树形结构表设计与优化
在诸多的管理类,办公类等系统中,树形结构展示随处可见,本文主要介绍了mysql 树形结构表设计与优化,具有一定的参考价值,感兴趣的小伙伴们可以参...
- Mysql
详解MySQL中的分组查询与连接查询语句
这篇文章主要介绍了MySQL中的分组查询与连接查询语句,同时还介绍了一些统计函数的用法,需要的朋友可以参考下 ...
- Mysql
mysql 不能插入中文问题
当向mysql5.5插入中文时,会出现类似错误 ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column ...
- Mysql
ERROR: Error in Log_event::read_log_event()
ERROR: Error in Log_event::read_log_event(): read error, data_len: 438, event_type: 2 ...
- Mysql
MySQL锁的知识点总结
在本篇文章里小编给大家整理了关于MySQL锁的知识点总结以及实例内容,需要的朋友们学习下。...
- Mysql
MySQL 数据备份与还原的示例代码
这篇文章主要介绍了MySQL 数据备份与还原的相关知识,本文通过示例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下...
- Mysql
解决MySQl查询不区分大小写的方法讲解
今天小编就为大家分享一篇关于解决MySQl查询不区分大小写的方法讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起...