• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Mysql > 使用mysqlfrm恢复frm表结构的方法

使用mysqlfrm恢复frm表结构的方法

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-05

匿名通过本文主要向大家介绍了mysqlfrm,方法,结构等相关知识,希望本文的分享对您有所帮助
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.

以上就是使用mysqlfrm恢复frm表结构的方法 的详细内容,更多请关注微课江湖其它相关文章!

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 使用mysqlfrm恢复frm表结构的方法

相关文章

  • 2018-12-05MySQL 分表优化试验代码
  • 2018-12-05mysql database manual(mysql数据库手册)
  • 2018-12-05MySQL 语句大全:创建、授权、查询、修改
  • 2017-05-11MySQL数据库开启、关闭、查看函数功能的方法
  • 2018-12-05ORACLE常用数值函数、转换函数、字符串函数
  • 2018-12-05关于mysql_info()函数的10篇文章推荐
  • 2017-05-11mysql时间戳转成常用可读时间格式的两种方法
  • 2018-12-05详解MySQL数据库中有关source命令
  • 2018-12-05MySQL NULL 值处理实例教程
  • 2018-12-05mysql_fetch_field()函数的用法汇总

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • Mysql中实现提取字符串中的数字的自定义函数分享
    • mysql:Can't start server: can't create PID file: No space left on device
    • mysql触发器简介及如何创建和删除触发器
    • mssql2005字符串连接方法 避免无效的连接错误
    • MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
    • 根据日期知道当天是星期几的手动计算方法
    • 免安转MySQL服务的启动与停止方法
    • MySQL安全输入密码的一些操作介绍
    • 把数据批量插入具有Identity列的表的方法
    • RavenDB在传统C/S应用下的一点实践

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有