Mysql-实现dblink

版本

1
Server version: 8.0.23 MySQL Community Server - GPL

查看引擎

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

#federated 有安装但没有开启

设置参数并重启数据库

1
2
3
echo "federated" >>/etc/my.cnf

systemctl restart mysqld

例子

1
2
3
4
5
CREATE TABLE `t_tasks_operate` (
`id` bigint NOT NULL COMMENT '主键ID',
`tasks_id` bigint DEFAULT NULL COMMENT '调度任务id',
KEY `tasks_id_index` (`tasks_id`) USING BTREE
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT CONNECTION='mysql://root:123456@192.168.1.1:3306/farm_test/t_tasks_operate' ;