0

0

Oracle access MySql via unixODBC by DBLINK

php中文网

php中文网

发布时间:2016-06-07 17:27:43

|

1344人浏览过

|

来源于php中文网

原创

对MySql了解仅限于通用的SQL语句,其他完全不懂;但是我知道至少有超过2中以上的办法来实现这个需求。他这里应该是借助unixODBC来

原来公司的同事询问了一个问题:
 我问一下oracle连接远程mysql的方法 我之前用hsodbc 但是不能显示不同属性的字段
oracle好像也没for mysql的透明网关  请问有什么方法能远程获取mysql的数据? 我oracle专门做分析的 会调用mysql的数据 所以就要获取mysql的数据 又不想做同步
 ------------、
 
介个你懂吗


对MySql了解仅限于通用的SQL语句,其他完全不懂;但是我知道至少有超过2中以上的办法来实现这个需求。
 他这里应该是借助unixODBC来访问MySql的数据,以下是测试过程。
 环境:
 MySql5.6 For Windows2003
 Oracle10G For CentOS5.7
 
0. MySql安装部署数据准备
 MySql在windows2003上的安装部署非常简单,,简单的一步一步next就好了,这里略过,我们将创建一个数据库用户gtlions,创建一个表access_by_oracle并插入几条测试数据。
 C:\Documents and Settings\Administrator>mysql -u root -p
 Enter password: ******
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 2
 Server version: 5.6.10-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
 affiliates. Other names may be trademarks of their respective
 owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> help
 
For information about MySQL products and services, visit:
   
 For developer information, including the MySQL Reference Manual, visit:
   
 To buy MySQL Enterprise support, training, or other products, visit:
    https://shop.mysql.com/
 
List of all MySQL commands:
 Note that all text commands must be first on line and end with ';'
 ?        (\?) Synonym for `help'.
 clear    (\c) Clear the current input statement.
 connect  (\r) Reconnect to the server. Optional arguments are db and host.
 delimiter (\d) Set statement delimiter.
 ego      (\G) Send command to mysql server, display result vertically.
 exit      (\q) Exit mysql. Same as quit.
 go        (\g) Send command to mysql server.
 help      (\h) Display this help.
 notee    (\t) Don't write into outfile.
 print    (\p) Print current command.
 prompt    (\R) Change your mysql prompt.
 quit      (\q) Quit mysql.
 rehash    (\#) Rebuild completion hash.
 source    (\.) Execute an SQL script file. Takes a file name as an argument.
 status    (\s) Get status information from the server.
 tee      (\T) Set outfile [to_outfile]. Append everything into given outfile.
 use      (\u) Use another database. Takes database name as argument.
 charset  (\C) Switch to another charset. Might be needed for processing binlog
 with multi-byte charsets.
 warnings  (\W) Show warnings after every statement.
 nowarning (\w) Don't show warnings after every statement.
 
For server side help, type 'help contents'
 mysql> CREATE USER 'gtlions'@'%' IDENTIFIED BY '000000';
 ERROR 1396 (HY000): Operation CREATE USER failed for 'gtlions'@'%'
 mysql> CREATE USER 'gtlions' IDENTIFIED BY '000000';
 Query OK, 0 rows affected (0.00 sec)
 
mysql> GRANT USAGE ON * . * TO 'gtlions' IDENTIFIED BY '000000' WITH MAX_QUERIES
 _PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIO
 NS 0 ;
 Query OK, 0 rows affected (0.00 sec)
 
mysql> CREATE DATABASE IF NOT EXISTS `gtlions` ;
 Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON `gtlions` . * TO 'gtlions';
 Query OK, 0 rows affected (0.00 sec)
 
mysql>exit
 Bye
 C:\Documents and Settings\Administrator>mysql -u gtlions -p
 Enter password: ******
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 22
 Server version: 5.6.10-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
 affiliates. Other names may be trademarks of their respective
 owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> use gtlions
 Database changed
 mysql> create table access_by_oracle(id int(5),name char(20));
 Query OK, 0 rows affected (0.09 sec)
 
mysql> insert into access_by_oracle values(1,'gtlions');
 Query OK, 1 row affected (0.00 sec)
 
mysql> insert into access_by_oracle values(2,'laidye');
 Query OK, 1 row affected (0.00 sec)
 
mysql> select * from access_by_oracle;
 +------+---------+
 | id  | name    |
 +------+---------+
 |    1 | gtlions |
 |    2 | laidye  |
 +------+---------+
 2 rows in set (0.00 sec)
 
mysql>

linux

相关专题

更多
nginx部署php项目教程汇总
nginx部署php项目教程汇总

本专题整合了nginx部署php项目教程汇总,阅读专题下面的文章了解更多详细内容。

0

2026.01.13

PHP 表单处理与文件上传安全实战
PHP 表单处理与文件上传安全实战

本专题聚焦 PHP 在表单处理与文件上传场景中的实战与安全问题,系统讲解表单数据获取与校验、XSS 与 CSRF 防护、文件类型与大小限制、上传目录安全配置、恶意文件识别以及常见安全漏洞的防范策略。通过贴近真实业务的案例,帮助学习者掌握 安全、规范地处理用户输入与文件上传的完整开发流程。

5

2026.01.13

PPT交互图表教程大全
PPT交互图表教程大全

本专题整合了PPT交互图表相关教程汇总,阅读专题下面的文章了解更多详细内容。

53

2026.01.12

Java 项目构建与依赖管理(Maven / Gradle)
Java 项目构建与依赖管理(Maven / Gradle)

本专题系统讲解 Java 项目构建与依赖管理的完整体系,重点覆盖 Maven 与 Gradle 的核心概念、项目生命周期、依赖冲突解决、多模块项目管理、构建加速与版本发布规范。通过真实项目结构示例,帮助学习者掌握 从零搭建、维护到发布 Java 工程的标准化流程,提升在实际团队开发中的工程能力与协作效率。

21

2026.01.12

c++主流开发框架汇总
c++主流开发框架汇总

本专题整合了c++开发框架推荐,阅读专题下面的文章了解更多详细内容。

135

2026.01.09

c++框架学习教程汇总
c++框架学习教程汇总

本专题整合了c++框架学习教程汇总,阅读专题下面的文章了解更多详细内容。

66

2026.01.09

学python好用的网站推荐
学python好用的网站推荐

本专题整合了python学习教程汇总,阅读专题下面的文章了解更多详细内容。

140

2026.01.09

学python网站汇总
学python网站汇总

本专题整合了学python网站汇总,阅读专题下面的文章了解更多详细内容。

13

2026.01.09

python学习网站
python学习网站

本专题整合了python学习相关推荐汇总,阅读专题下面的文章了解更多详细内容。

19

2026.01.09

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
SQL 教程
SQL 教程

共61课时 | 3.4万人学习

燕十八Oracle视频教程
燕十八Oracle视频教程

共31课时 | 7.2万人学习

动力节点mysql基础视频教程
动力节点mysql基础视频教程

共86课时 | 18.2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号