engines进行数据库表映射 MySql

MySql版本:5.7.7
操作系统:Windows

1.安装federated引擎

install plugin federated soname ‘ha_federated.so’;
可以在cmd中使用mysql -u用户名 -p密码登录mysql

2.查看federated引擎是否开启

Navicat或cmd登录mysql中输入命令show engines;查看是否开启federated引擎。
engines进行数据库表映射 MySql

如果显示为NO,需要找到mysql的安装根目录的my.ini文件,任意位置添加federated。然后服务重启mysql服务
注:cmd中可用net stop mysql;和net stop start;重启服务。
engines进行数据库表映射 MySql

3.执行需要映射表sql

这里拿mysql中新建的连接中,数据库名为mysql的proc表做演示。

CREATE TABLE proc (
db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ‘’,
name char(64) NOT NULL DEFAULT ‘’,
type enum(‘FUNCTION’,‘PROCEDURE’) NOT NULL,
specific_name char(64) NOT NULL DEFAULT ‘’,
language enum(‘SQL’) NOT NULL DEFAULT ‘SQL’,
sql_data_access enum(‘CONTAINS_SQL’,‘NO_SQL’,‘READS_SQL_DATA’,‘MODIFIES_SQL_DATA’) NOT NULL DEFAULT ‘CONTAINS_SQL’,
is_deterministic enum(‘YES’,‘NO’) NOT NULL DEFAULT ‘NO’,
security_type enum(‘INVOKER’,‘DEFINER’) NOT NULL DEFAULT ‘DEFINER’,
param_list blob NOT NULL,
returns longblob NOT NULL,
body longblob NOT NULL,
definer char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ‘’,
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
modified timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
sql_mode set(‘REAL_AS_FLOAT’,‘PIPES_AS_CONCAT’,‘ANSI_QUOTES’,‘IGNORE_SPACE’,‘NOT_USED’,‘ONLY_FULL_GROUP_BY’,‘NO_UNSIGNED_SUBTRACTION’,‘NO_DIR_IN_CREATE’,‘POSTGRESQL’,‘ORACLE’,‘MSSQL’,‘DB2’,‘MAXDB’,‘NO_KEY_OPTIONS’,‘NO_TABLE_OPTIONS’,‘NO_FIELD_OPTIONS’,‘MYSQL323’,‘MYSQL40’,‘ANSI’,‘NO_AUTO_VALUE_ON_ZERO’,‘NO_BACKSLASH_ESCAPES’,‘STRICT_TRANS_TABLES’,‘STRICT_ALL_TABLES’,‘NO_ZERO_IN_DATE’,‘NO_ZERO_DATE’,‘INVALID_DATES’,‘ERROR_FOR_DIVISION_BY_ZERO’,‘TRADITIONAL’,‘NO_AUTO_CREATE_USER’,‘HIGH_NOT_PRECEDENCE’,‘NO_ENGINE_SUBSTITUTION’,‘PAD_CHAR_TO_FULL_LENGTH’) NOT NULL DEFAULT ‘’,
comment text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
character_set_client char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
collation_connection char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
db_collation char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
body_utf8 longblob,
PRIMARY KEY (db,name,type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC CONNECTION=‘mysql://root:root@127.0.0.1:3306/mysql/proc’;

表结构+ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC+
ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC +
CONNECTION=‘mysql://用户名:密码@需要映射数据库IP:端口/数据库名/表名’;

上一篇:autojs之停止脚本的6种方法


下一篇:mysql的存储引擎