mysqlfrm使用
【1】下载安装
【1.1】下载
下载官网:https://downloads.mysql.com/archives/utilities/
linux:wget https://downloads.mysql.com/archives/get/p/30/file/mysql-utilities-1.6.5.tar.gz
【1.2】二进制编辑安装
#前置条件,python2.6及以上
tar -xvzf mysql-utilities-1.6.5.tar.gz cd mysql-utilities-1.6.5 python ./setup.py build python ./setup.py install
【1.3】检查是否安装好
mysqlfrm --version
【2】参数介绍与使用
【2.1】参数介绍
--basedir :如 --basedir=/usr/local/percona-5.6.21 --server : 如 --server=user:password@192.168.1.100:3306 --diagnostic : 开启按字节模式来恢复frm结构 --user :启动MySQL用户,通过为mysql
【2.2】使用 --basedir 模式
(1)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;
【2.3】使用--server方式恢复
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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2018-03-19 SQLServer 2008以上误操作数据库恢复方法——日志尾部备份