mysql frm_mysqlfrm初步使用

这个工具也就是读取frm文件生成建表语句

默认的模式是再生个实例,使用--basedir选项或指定--server选项来连接到已经安装的实例。这种过程不会改变原始的.frm文件。该模式也需要指定--port选项来给再生的实例使用,该端口不能与现有的实例冲突。在读取.frm文件后,再生的实例将被关闭,所有的临时文件将被删除的。

诊断模式,需要指定 --diagnostic 选项。byte-by-byte读取.frm文件 尽可能多的恢复信息。该模式有更多的局限性,不能校验字符集;使用默认模式无法读取文件或者该服务器上没有安装MySQL实例就使用诊断模式。

安装

需要先安装mysql-connector-python

wget https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.7-1.el6.x86_64.rpm

wget ftp://ftp.pbone.net/mirror/dev.mysql.com/pub/Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el6.noarch.rpm

wget ftp.pbone.net/mirror/dev.mysql.com/pub/Downloads/MySQLGUITools/mysql-utilities-extra-1.5.6-1.el6.noarch.rpm

使用需要指定.frm文件的路径,也可以指定一个目录,该目录下的所有.frm文件将被读取

默认模式

mysqlfrm --server=root:ocm123@localhost --user=root --port=3307 /data/mysql/ht/tb.frm

mysqlfrm --basedir=/usr --port=3307--user=mysql /data/mysql/ht/tb.frm --show-stats

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[root@redis01 ~]# mysqlfrm --server=root:ocm123@localhost --user=root --port=3307 /data/mysql/ht/tb.frm

WARNING: Using a password on the command lineinterfacecan be insecure.

# Source on localhost: ... connected.

# Spawning server with--user=root.

# Starting the spawned server on port3307... done.

# Reading .frm files

#

# Reading the tb.frm file.

#

# CREATE statementfor /data/mysql/ht/tb.frm:

#

CREATE TABLE `ht`.`tb` (

`id`int(11) NOT NULL,

`name` varchar(16) DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8

#...done.

[root@redis01~]# mysqlfrm --basedir=/usr --port=3307 --user=mysql /data/mysql/ht/tb.frm --show-stats

# Spawning server with--user=mysql.

# Starting the spawned server on port3307 ... ERROR Attempting to stop failed spawned server. Process id = 21404.

ERROR: Spawn server operation failed. Clone server error: Unable to communicate withnew instance. Process id = 21404.. To diagnose, run the utility again and use the --verbose option to view the messages fromthe spawned server and correct any errors presented then run the utility again.

[root@redis01~]# mysqlfrm --basedir=/usr --port=3307 --user=root /data/mysql/ht/tb.frm --show-stats

# Spawning server with--user=root.

# Starting the spawned server on port3307... done.

# Reading .frm files

#

# Reading the tb.frm file.

#

# CREATE statementfor /data/mysql/ht/tb.frm:

#

CREATE TABLE `ht`.`tb` (

`id`int(11) NOT NULL,

`name` varchar(16) DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8

# File Statistics:

# Last Modified : Sat Jun30 10:06:11 2018# Creation Time : Sat Jun30 10:06:11 2018# Last Accessed : Sat Jun30 10:06:11 2018# Mode :33184# Size :8586# Table Statistics:

# Engine : HEAP

# frm Version :10# MySQL Version :5.7.22# frm File_Version :5# IO_SIZE :4096# Def Partition Engine : None

#...done.

View Code

诊断模式

mysqlfrm --diagnostic /data/mysql/ht/tb.frm --show-stats

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[root@redis01 ~]# mysqlfrm --diagnostic /data/mysql/ht/tb.frm --show-stats

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

# CAUTION: The diagnostic modeis 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 forthe columns and the resulting statement may not be syntactically correct.

# Reading .frm filefor /data/mysql/ht/tb.frm:

# The .frm fileisa TABLE.

# CREATE TABLE Statement:

CREATE TABLE `ht`.`tb` (

`id`int(11) NOT NULL,

`name` varchar(48) DEFAULT NULL,

PRIMARY KEY `PRIMARY` (`id`)

) ENGINE=InnoDB;

# File Statistics:

# Last Modified : Thu Jun28 05:57:24 2018# Creation Time : Thu Jun28 05:57:47 2018# Last Accessed : Fri Jun29 23:01:23 2018# Mode :33184# Size :8586# Table Statistics:

# Engine : INNODB

# frm Version :10# MySQL Version :5.7.22# frm File_Version :5# IO_SIZE :4096# Def Partition Engine : None

#...done.

View Code

选项

某些引擎表在默认模式下不可读取的。如PARTITION, PERFORMANCE_SCHEMA,必需在诊断模式下可读。

要在创建语句中改变存储引擎,可使用--new-storage-engine 选项。如果有指定该选项,同时必须指定--frmdir选项,该工具生成新的.frm文件,前缀为new_,并保存在--frmdir目录下。

关掉所有信息除了CREATE 语句和警告或错误信息,使用--quiet选项。

使用--show-stats 选项统计每个.frm文件信息。

使用--user 选项指定再生的实例以哪个权限运行。

如果再生的实例超过10秒启动,需调大--start-timeout 选项参数。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值