DM->mysql dblink
1安装mysql odbc
rpm -ivh mysql-connector-odbc-5.3.14-1.el7.x86_64.rpm
2mysql创建远程用户与远程数据库
mysql> show databases;
+-------------------------+
| Database |
+-------------------------+
| information_schema |
| mysql |
| #mysql50#mysql-bin-obar |
| performance_schema |
| sys |
+-------------------------+
5 rows in set (0.00 sec)
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql> use test
Database changed
mysql> create table test ( id int ,name varchar(20));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into test (id,name) values (1,'nihao');
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on test.* to 'root'@'%' IDENTIFIED BY 'njnu123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
连接测试
[root@mysqlre1 ~]# mysql -ukingle -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 747202
Server version: 5.7.26-log Source distribution
Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
mysql>
3 配置unixodbc
msyql5.7.33
vim odbc.ini
[mysql]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc8w.so
Server = 192.168.0.187
Port = 3306 ----mysql 端口
User = root ----mysql连接用户
Password = 123456 ---mysql 连接密码
Database = test ---mysql连接数据库
[mysql]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5w.so
Server = 192.168.142.243
Port = 3306
User = root
Password = njnu123456
Database = test
[mysqlodbc]
Driver = MySQL ODBC 5.3 Unicode Driver
SERVER = 192.168.142.243
PORT = 3306
USER = root
PASSWORD = 此处是密码
CHARSET= gbk
DATABASE= test
OPTION = 3
TRACE = OFF
vim /etc/odbcinst.ini
[MySQL ODBC 5.3 Unicode Driver]
Driver=/usr/lib64/libmyodbc5w.so
UsageCount=1
创建语句
create or replace public LINK link_mysqlodbc connect 'ODBC' with "root" identified by "此处是密码" using 'mysqlodbc';
select * from "test"."test"@LINK_MYSQLODBC;
insert into "test"."test"@LINK_MYSQLODBC VALUES(2,'您好');
mysql->DM dblink
若需要创建FEDERATED引擎表,则目标端实例要开启FEDERATED引擎。从MySQL5.5开始FEDERATED引擎默认安装 只是没有启用,进入命令行输入show engines;
FEDERATED行状态为NO。
后续进行补充
更多资讯请上达梦技术社区了解: https://eco.dameng.com