如何从 .myd、.myi、.frm 文件恢复 MySQL 数据库 [英] How to recover MySQL database from .myd, .myi, .frm files

查看:101
本文介绍了如何从 .myd、.myi、.frm 文件恢复 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 .myd.myi.frm 文件恢复我的 MySQL 数据库之一?

How to restore one of my MySQL databases from .myd, .myi, .frm files?

推荐答案

如果这些是 MyISAM 表,则将 .FRM、.MYD 和 .MYI 文件放入数据库目录(例如,/var/lib/mysql/dbname) 将使该表可用.它不必是与它们来自相同的数据库、相同的服务器、相同的 MySQL 版本或相同的体系结构.您可能还需要更改文件夹的所有权(例如,chown -R mysql:mysql/var/lib/mysql/dbname)

If these are MyISAM tables, then plopping the .FRM, .MYD, and .MYI files into a database directory (e.g., /var/lib/mysql/dbname) will make that table available. It doesn't have to be the same database as they came from, the same server, the same MySQL version, or the same architecture. You may also need to change ownership for the folder (e.g., chown -R mysql:mysql /var/lib/mysql/dbname)

请注意,权限(GRANT 等)是 mysql 数据库的一部分.所以它们不会和桌子一起恢复;您可能需要运行适当的 GRANT 语句来创建用户、授予访问权限等.(恢复 mysql 数据库是可能的,但您需要小心 MySQL 版本和mysql_upgrade 实用程序所需的任何运行.)

Note that permissions (GRANT, etc.) are part of the mysql database. So they won't be restored along with the tables; you may need to run the appropriate GRANT statements to create users, give access, etc. (Restoring the mysql database is possible, but you need to be careful with MySQL versions and any needed runs of the mysql_upgrade utility.)

实际上,您可能只需要 .FRM(表结构)和 .MYD(表数据),但您必须修复表以重建 .MYI(索引).

Actually, you probably just need the .FRM (table structure) and .MYD (table data), but you'll have to repair table to rebuild the .MYI (indexes).

唯一的限制是,如果您要降级,最好查看发行说明(并可能运行修复表).当然,较新的 MySQL 版本会添加功能.

The only constraint is that if you're downgrading, you'd best check the release notes (and probably run repair table). Newer MySQL versions add features, of course.

[虽然应该很明显,如果你混合和匹配表,这些表之间关系的完整性是你的问题;MySQL 不会关心,但您的应用程序和您的用户可能会关心.此外,此方法对 InnoDB 表根本不起作用.只有 MyISAM,但考虑到你拥有的文件,你有 MyISAM]

[Although it should be obvious, if you mix and match tables, the integrity of relationships between those tables is your problem; MySQL won't care, but your application and your users may. Also, this method does not work at all for InnoDB tables. Only MyISAM, but considering the files you have, you have MyISAM]

这篇关于如何从 .myd、.myi、.frm 文件恢复 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆