1、mysqlfrm安装

-----------------------------

由于mysqlfrm是mysql-utilities工具一部分,那么我们安装mysql-utilities即可,下载好对应的源码包,进行编译安装。

shell> tar -xvzf mysql-utilities-1.6.4.tar.gz

shell> cd mysql-utilities-1.6.4

shell> python ./setup.py build

shell> python ./setup.py install

安装完成后,在相应的python执行目录下,就能mysqlfrm等执行文件了。

2、mysqlfrm相关参数介绍

-------------------------------

--basedir :如 --basedir=/usr/local/percona-5.6.21

--server : 如 --server=user:password@192.168.1.100:3306

--diagnostic : 开启按字节模式来恢复frm结构

--user :启动MySQL用户,通过为mysql

3、mysqlfrm使用

-------------------------

使用--basedir模式恢复:

[ 16:35:29-root@br3cy1sw:~ ]# mysqlfrm --basedir=/usr/local/percona-5.6.21/ /root/t1.frm --port=3434 --user=mysql --diagnostic

# WARNING The --port option is not used in the --diagnostic mode.

# WARNING: The --user option is only used for the default mode.

# WARNING: Cannot generate character set or collation names without the --server option.

# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.

# Reading .frm file for /root/t1.frm:

# The .frm file is a TABLE.

# CREATE TABLE Statement:

CREATE TABLE `root`.`t1` (

`a` int(11) NOT NULL,

`b` int(11) DEFAULT NULL,

`c` int(11) DEFAULT NULL,

`d` varchar(600) DEFAULT NULL,

PRIMARY KEY `PRIMARY` (`a`),

KEY `idx_t1_bc` (`b`,`c`)

) ENGINE=InnoDB;

#...done.

使用--server方式恢复:

[ 16:35:10-root@br3cy1sw:~ ]#mysqlfrm --server=user:password@192.168.1.100:3306 /root/t1.frm --port=3434 --user=mysql --diagnostic

WARNING: Using a password on the command line interface can be insecure.

# WARNING The --port option is not used in the --diagnostic mode.

# WARNING: The --user option is only used for the default mode.

# Source on 192.168.1.100: ... connected.

# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.

# Reading .frm file for /root/t1.frm:

# The .frm file is a TABLE.

# CREATE TABLE Statement:

CREATE TABLE `root`.`t1` (

`a` int(11) NOT NULL,

`b` int(11) DEFAULT NULL,

`c` int(11) DEFAULT NULL,

`d` varchar(200) COLLATE `utf8_general_ci` DEFAULT NULL,

PRIMARY KEY `PRIMARY` (`a`),

KEY `idx_t1_bc` (`b`,`c`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#...done.

注意到没有,使用--basedir恢复出来的varchar竟然是--server模式的3倍;这应该是mysqlfrm在使用basedir模式时,无法进行字符编码校验所致引起的。

再次看了下--server的文件:(重点看标红加粗的文字),建议:能用--server模式时,尽量使用--server同时保证提供mysqld环境与原生产环境的一致。

--server=server

Connection information for a server. Use this option or --basedir for the default mode.If provided with the diagnostic mode, the storage engine and character set information are validated against this server.

4、参考资料:

mysqlfrm官方文档

https://dev.mysql.com/doc/mysql-utilities/1.5/en/mysqlfrm.html

mysql frm 修复_使用mysqlfrm恢复frm表结构相关推荐

  1. mysql数据库对比工具、mysqldiff、数据库表结构变动对比

    mysql数据库对比工具.mysqldiff.数据库表结构变动对比 1.首先你要有 Navicat Premium 15,然后找到工具-结构同步 2.找到需要对比的数据库 3.点击比对 4.点击部署 ...

  2. mysql frm恢复数据_MYSQL使用.frm恢复数据表结构的实现方法

    我们都知道当我们建立数据表(innodb或myisam)时,会生成相应的文件(如:MYD,MYI,frm) 在这里,我们探讨下使用frm文件恢复 innodb和myisam类型表的结构,不过由于他们存 ...

  3. mysql frm 恢复_mysql 从 frm 文件恢复 table 表结构的3种方法

    mysql 正常运行的时候,查看 table 的结构并不是困难的事. 但是有时 mysql 发生故障,这种方法便不再可行. 当遇到故障,通常使用新的 mysql 实例来恢复当前的数据. 建表是非常重要 ...

  4. mysql frm ibd 创建表_MySQL数据库实现从.frm文件和.ibd文件恢复数据表方法

    MySQL中.frm文件:保存了每个表的元数据,包括表结构的定义等,该文件与数据库引擎无关. MySQL中.ibd文件:InnoDB引擎开启了独立表空间(my.ini中配置innodb_file_pe ...

  5. mysql停止修复_浅析MySQL 8.0崩溃恢复

    本文将结合MySQL 8.0.19 分析InnoDB崩溃恢复的拉起过程,包括恢复前的准备工作,redo回放,undo回滚,以及崩溃恢复后Crash Safe DDL的实现.其中重点介绍redo的回放. ...

  6. mysql创建复杂表_数据库_MySQL_复杂的表结构创建

    本例示例下复杂的表结构创建, 大致分为两张表 user表 和 authority(权限表) 每个用户对应一种权限,默认为1(普通用户)  灵感来源:(仿照 进程的优先级, 优先级越高的进程,数字越小) ...

  7. Mysql数据库基础系列(二):表结构、键值

    表结构 约束条件 查看约束条件 mysql> desc 库名.表名; 字段名----| 类型---------------| 空------ |键值-- |默认值---- |额外设置 | 设置约 ...

  8. python获取数据库查询的元数据_Python数据库、MySQL存储引擎、使用分区表、更改表结构、获取数据库元数据...

    :1. 数据库基本操作 1.1 创建数据库 - CREATE DATABASE test; #创建数据库 - GRANT ALL ON test.* to user(s); #为指定用户(或所有用户) ...

  9. oracle数据库复制mysql,MySQL/Oracle数据库,使用SQL快速复制表结构或数据

    创建表,并复制数据 create table table1 as select * from table2; 只创建表结构,不复制数据 create table table1 as select * ...

  10. vc mysql init 崩溃_故障分析 | 崩溃恢复巨慢原因分析

    作者:xuty 本文来源:原创投稿 *爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源. 一.现象 有个 MySQL 5.7 开发库异常挂掉后,奔溃恢复一直处于如下位置,且持 ...

最新文章

  1. 图片质量低怎么办?这个网站很不错!
  2. 作为一名程序员为什么要用vim作为自己的IDE编辑器
  3. 52个实用的数据可视化工具!
  4. C与C++中的extern与static、extern C与__cplusplus的作用
  5. LiveLayout
  6. 如何解决sqlserver 2005 备份的时候无法选择除系统盘外的其他盘符?
  7. 【转】Mac端包管理工具——Homebrew简介及安装
  8. UE4打包并加载Pak-Windows/iOS/Android不同平台Editor/Runtime不同运行模式兼容
  9. MATLAB app designer中全局变量的使用
  10. vscode中setting的设置
  11. pdf不预览直接打印(笔记记录)
  12. qqpcmgr_docpro 这个隐藏文件无法删除的问题解决方法
  13. 设置google搜索页面呈现方式
  14. 加入洛谷OJ,开通洛谷博客
  15. R语言plotly可视化:使用plotly可视化模型预测真阳性率(True positive)TPR和假阳性率(False positive)FPR在不同阈值(threshold)下的曲线
  16. JVM性能调优监控工具jps、jstack、jmap、jhat、jstat使用详解
  17. c语言里主函数指什么,C语言里的主函数是什么
  18. win10彻底关闭windows defender,解决无故占用大量CPU问题
  19. Linux下自动重启系统
  20. 2108 课前资料说明

热门文章

  1. 服务器导出表为dmp文件,mysql数据库导出dmp文件
  2. 通过漫画学习MySQL索引及优化
  3. 如何监控前端页面FPS
  4. ★Kali信息收集~ 5.The Harvester:邮箱挖掘器
  5. 【Vivado那些事】OOC综合方式
  6. Oracle 12C新特性总结
  7. Android:方向传感器
  8. 程序员搞什么副业好?
  9. DEBIAN_FRONTEND noninteractive参数
  10. 时间记录APP———Time Meter