0、获取建表语句
安装 mysqlfrm,执行以下命令:
mysqlfrm –diagnostic /data/db/manna/view_device_company_list.frm –show-stats
1、建表
CREATE TABLE `info_location` (
`location_id` bigint(22) NOT NULL AUTO_INCREMENT,
`enum_location_type` int(11) NOT NULL DEFAULT ‘1’ COMMENT ‘位置的类型’,
`longitude` float(16,8) NOT NULL DEFAULT ‘0.00000000’ COMMENT ‘经度’,
`latitude` float(16,8) NOT NULL DEFAULT ‘0.00000000’ COMMENT ‘纬度’,
`address` varchar(256) COLLATE utf8_unicode_ci NOT NULL DEFAULT ” COMMENT ‘大概地址’,
`region` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT ” COMMENT ‘地区’,
`subdistrict` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT ” COMMENT ‘小区,分区’,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`creater_id` int(11) NOT NULL DEFAULT ‘-1′,
PRIMARY KEY (`location_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC COMMENT=’位置信息表’;
# 删除表
# DROP TABLE info_location;
2、解除绑定
ALTER TABLE info_location DISCARD TABLESPACE;
3、停掉 mysql 服务
systemctl stop mysql
4、复制 ibd 文件
略。
5、授予权限(重要)
chown mysql.mysql info_locaiton.ibd
6、启动 mysql 服务
systemctl start mysql
7、恢复绑定
ALTER TABLE info_location IMPORT TABLESPACE;
参考文章:
https://www.cnblogs.com/gered/p/12524586.html
http://www.ttlsa.com/mysql/mysql-utilities-mysqlfrm/
https://blog.csdn.net/qq_34404803/article/details/78560153
https://blog.csdn.net/hzw19920329/article/details/78045864/