使用mysqlfrm恢复frm表结构的方法
1、mysqlfrm安装
由于mysqlfrm是mysql-utilities工具一部分,那么我们安装mysql-utilities即可,下载好对应的源码包,进行编译安装
shell> wget https://cdn.mysql.com/archives/mysql-utilities/mysql-utilities-1.6.5.tar.gz
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模式时,无法进行字符编码校验所致引起的。
使用mysqlfrm恢复frm表结构的方法的更多相关文章
- 使用mysqlfrm恢复frm表结构,获得建表语句
1.mysqlfrm 是一个恢复性质的工具,用来读取.frm文件并从该文件中找到表定义数据生成CREATE语句. 下载链接:https://downloads.mysql.com/archives/u ...
- mysql:恢复mysql表结构
mysql,frm格式恢复mysql表结构,以tuser.frm格式为例 新增数据库,如下,创建数据库名为ab 打开数据库,双击打开数据库 点右键新建表结构 新增表,里面只添加一个字段 ...
- Oracle查看表结构的方法【我】
Oracle查看表结构的方法 方法一: 在命令窗口下输入 DESC table_name; 回车 方法二: 在sql窗口下 SELECT DBMS_METADATA.GET_ ...
- mysql 从 frm 文件恢复 table 表结构的3种方法
mysql 正常运行的时候,查看 table 的结构并不是困难的事. 但是有时 mysql 发生故障,这种方法便不再可行. 当遇到故障,通常使用新的 mysql 实例来恢复当前的数据. 建表是非常重要 ...
- 通过.frm表结构和.ibd文件恢复数据
整个恢复过程其实可以总结为下面几步: (1):恢复表结构 (2):复制出来创建表的sql语句 (3):恢复表数据(在恢复表数据的时候,首先需要解除当前创建的表与默认生成的.ibd文件间的关系,接着将要 ...
- DbHelperSQL 判断数据库表结构公用方法
#region 公用方法 /// <summary> /// 判断是否存在某表的某个字段 /// </summary> ...
- jdbctemplate 获取数据表结构的方法&注意事项
方法一 直接查询: SqlRowSet srcSqlRowSet = srcJdbcTemplate.queryForRowSet("SELECT * FROM tablename LIMI ...
- mysql大数据量下修改表结构的方法
http://www.blogjava.net/anchor110/articles/361152.html
- MySQL只有.frm文件恢复表结构
http://www.ttlsa.com/mysql/mysql-utilities-mysqlfrm/ 以诊断模式读取目录中的所有的FRM文件: D:\Program Files (x86)\Eas ...
随机推荐
- cogs 2109. [NOIP 2015] 运输计划 提高组Day2T3 树链剖分求LCA 二分答案 差分
2109. [NOIP 2015] 运输计划 ★★★☆ 输入文件:transport.in 输出文件:transport.out 简单对比时间限制:3 s 内存限制:256 MB [题 ...
- HttpServletRequest & HttpServletResponse
Servlet配置方式 全路径匹配 以 / 开始 /aa/bb localhost:8080/项目名称/aa/bb 路径匹配 , 前半段匹配 以 / 开始 , 但是以 * 结束 /a/* /* *是一 ...
- Spring中bean的实例化过程
1.从缓存中.优先从一级缓存中拿,有则返回. 如果没有,则从二级缓存中获取,有则返回. 如果二级缓存中拿不到,则从三级缓存中拿,能拿到,则从三级缓存中删除,移到二级缓存. 如果三级缓存也没有,则返回n ...
- Filder配置及使用教程
https://www.cnblogs.com/woaixuexi9999/p/9247705.html
- Scrapy定制起始请求
Scrapy引擎来爬虫中取起始的URL 1.调用start_requests方法(父类),并获取返回值 2.将放回值变成迭代器,通过iter() 3.执行__next__()方法取值 4.把返回值全部 ...
- CCPC-wannafly Camp Day2 讲课内容总结(杜瑜皓-数据结构)
·栈.单调栈 1.栈的特点与基本操作 2.单调栈 单调栈是一种特殊的栈,其栈内的元素都保持一个单调性(单调递增或者递减). ·单调递增栈,从栈底到栈顶依次递增(单调非递减栈:允许有相等) ·单调递减栈 ...
- java小心机(5)| 浅谈类成员初始化顺序
类成员什么时候会被初始化呢?一般来说:"类的代码在初次使用时才被加载",加载过程包括了初始化. 比如说new A()调用构造函数时,类中全部成员都会被初始化. 但对于static域 ...
- CentOS7 zabbix4.0搭建配置
一.Zabbix-Server服务器端的安装 概述:10050是Agent的端口,Agent采用被动方式,Server主动连接Agent的10050端口:10051是Server的端口,Agent采用 ...
- 记一次阿里云LVM扩容与 LVM 相关知识学习
一.lvm 扩容 问题: 我们阿里云服务器有一个磁盘容量为 1T ,但是最近由于业务的扩增,磁盘容量已经不够了,需要增大磁盘的容量.磁盘挂载在 /home,使用的是 LVM.我们现在需要对磁盘进行扩容 ...
- Kotlin DSL for HTML实例解析
Kotlin DSL for HTML实例解析 Kotlin DSL, 指用Kotlin写的Domain Specific Language. 本文通过解析官方的Kotlin DSL写html的例子, ...