How to recover MySQL database from .myd, .myi, .frm files(如何从 .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 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 .myd、.myi、.frm 文件恢复 MySQL 数据库


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 更改自动增量起始编号? 2021-01-01