57.MySQL-Utilities工具包之-mysqlfrm

文章介绍了如何使用mysqlfrm工具来诊断数据库下的表结构,以及生成建表语句。通过示例展示了对test数据库中test1和test2两个表的结构解析,强调了.FRM文件的二进制特性及其在没有--server选项时的限制。同时,提到了工具可以检测文件是否损坏,并且默认的字符集为latin1。
摘要由CSDN通过智能技术生成

1.诊断该数据库下的表结构。
[root@mysql1 ~]# mysqlfrm --diagnostic /mysql/mysql3306/test
# 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 /mysql/mysql3306/test/test1.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:

CREATE TABLE `test`.`test1` (
  `id` int(11) DEFAULT NULL, 
  `name` varchar(10) DEFAULT NULL 
) ENGINE=InnoDB;

# Reading .frm file for /mysql/mysql3306/test/test2.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:

CREATE TABLE `test`.`test2` (
  `id` int(11) DEFAULT NULL, 
  `name` varchar(20) DEFAULT NULL 
) ENGINE=InnoDB;

2.检查test数据库下:frm 生成建表语句。

解析test数据库下所有表的结构。
mysqlfrm --server=root:rootroot@localhost:3306 /mysql/mysql3306/test/ --port=3308 --user=mysql

或者:解析单个表的frm结构。
mysqlfrm --server=root:rootroot@localhost:3306 /mysql/mysql3306/test/test2.frm /mysql/mysql3306/test/test1.frm --port=3308 --user=mysql
WARNING: Using a password on the command line interface can be insecure.
# Source on localhost: ... connected.
# Spawning server with --user=mysql.
# Starting the spawned server on port 3308 ... done.
# Reading .frm files
# Reading the test1.frm file.
# CREATE statement for /mysql/mysql3306/test/test1.frm:
#
CREATE TABLE `test`.`test1` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Reading the test2.frm file.
# CREATE statement for /mysql/mysql3306/test/test2.frm:
CREATE TABLE `test`.`test2` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
#...done.

总结:

通常.frm 文件是二进制的无法直接看里面的内容,通过mysqlfrm 工具可以很方便的查看表的结构,同时可以检查文件是否损坏。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值