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

查看:503
本文介绍了如何从.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天全站免登陆