MySQL的 .frm .myi .myd 文件


搜索关键字:
  • mysql .frm .myi .myd
  • mysql .frm .myi .myd percona
参考内容:
  • .frm 保存的是表的结构
  • .MYD 保存的是表的数据记录
  • .MYI 保存的是表的索引

=

  • .FRM  =>  It has the table structure of your table or table definition
  • .MYI  =>  It has the indexes of your table
  • .MYD  =>  It contains your data

Engines Specific:

Innodb:

Innodb has only .frm files and it has its own tablespace where it contains indexes and datas and its shared in databases.

MyISAM:

MyIsam has all the three files. where .myi has your indexes, .myd has your table datas and .frm has its table definition.

==

A MySQL database creates a number of different data files in the mysql data directory (typically/var/lib/mysql). The following are the differences between the data files created:

File Extension Purpose
.frm table definition
.MYD table data
.MYI table indices

I believe these files are created for both MyISAM and InnoDB table types because the MySQL documentation references these types with respect to MyISAM and I definitely see them on my InnoDB tables.

==

参考链接:
,

《 “MySQL的 .frm .myi .myd 文件” 》 有 2 条评论

  1. 带你扒一扒 MySQL 的数据在磁盘上到底长什么样子…
    https://mp.weixin.qq.com/s/EP08i39J6Hu5xMV3fdcmCg
    `
    MySQL 中常用的存储引擎有两种:MyISAM 和 InnoDB。
    MySQL 5.5之前,MyISAM 是默认的存储引擎。
    MySQL 5.5开始,InnoDB 是默认的存储引擎。

    MyISAM 最致命的一点就是不支持事务,而 InnoDB 支持。所以现在 InnoDB 已经成为我们使用的标配、最主流的存储引擎了。

    # MyISAM
    每个 MyISAM 表都以3个文件存储在磁盘上。这些文件的名称以表名开头,以扩展名指示文件类型。

    .frm 文件(frame)存储表结构;
    .MYD 文件(MY Data)存储表数据;
    .MYI 文件(MY Index)存储表索引。

    MySQL 里的数据默认是存放在安装目录下的 data 文件夹中,也可以自己修改。

    # InnoDB
    一张 InnoDB 表底层会对应2个文件在文件夹中进行数据存储。

    .frm 文件(frame)存储表结构;
    .ibd 文件(InnoDB Data)存储表索引+数据。

    .ibd 存储数据的特点就是 B+tree 的叶子节点上包括了我们要的索引和该索引所在行的其它列数据。

    # 聚集(聚簇)索引
    聚集索引:叶子节点包含了完整的数据记录。

    简单来说就是索引和它所在行的其它列数据全部都在一起了。

    很显然,MyISAM 没有聚集索引,InnoDB 有,而且 InnoDB 的主键索引就是天然的聚集索引。
    有聚集索引当然就有非聚集索引(稀疏索引)。对于 MyISAM 来说,它的索引就是非聚集索引。因为它的索引和数据是分开两个文件存的:一个 .MYI 存索引,一个 .MYD 存数据。
    `

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注