• MySQL-数据目录


    一、MySQL的主要目录结构(MySQL 8)

    [root@localhost ~]# find / -name mysql
    find: ‘/proc/30845’: 没有那个文件或目录
    find: ‘/proc/30855’: 没有那个文件或目录
    /etc/logrotate.d/mysql
    /etc/selinux/targeted/active/modules/100/mysql
    /etc/selinux/targeted/tmp/modules/100/mysql
    /var/lib/mysql
    /var/lib/mysql/mysql
    /usr/bin/mysql
    /usr/lib64/mysql
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    1、数据库文件存放路径 /var/lib/mysql

    [root@localhost ~]# cd /var/lib/mysql
    [root@localhost mysql]# ll
    总用量 188872
    -rw-r-----. 1 mysql mysql       56 4月  20 02:37 auto.cnf
    -rw-r-----. 1 mysql mysql     1756 4月  21 01:15 binlog.000001
    -rw-r-----. 1 mysql mysql      156 4月  21 01:15 binlog.000002
    -rw-r-----. 1 mysql mysql       32 4月  21 01:15 binlog.index
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 ca-key.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 ca.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 client-cert.pem
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 client-key.pem
    -rw-r-----. 1 mysql mysql   196608 4月  21 01:18 #ib_16384_0.dblwr
    -rw-r-----. 1 mysql mysql  8585216 4月  20 02:36 #ib_16384_1.dblwr
    -rw-r-----. 1 mysql mysql     5472 4月  20 02:37 ib_buffer_pool
    -rw-r-----. 1 mysql mysql 12582912 4月  21 01:16 ibdata1
    -rw-r-----. 1 mysql mysql 50331648 4月  21 01:18 ib_logfile0
    -rw-r-----. 1 mysql mysql 50331648 4月  20 02:36 ib_logfile1
    -rw-r-----. 1 mysql mysql 12582912 4月  21 01:14 ibtmp1
    drwxr-x---. 2 mysql mysql      187 4月  21 01:14 #innodb_temp
    drwxr-x---. 2 mysql mysql      143 4月  20 02:37 mysql
    -rw-r-----. 1 mysql mysql 25165824 4月  21 01:15 mysql.ibd
    srwxrwxrwx. 1 mysql mysql        0 4月  21 01:16 mysql.sock
    -rw-------. 1 mysql mysql        5 4月  21 01:16 mysql.sock.lock
    drwxr-x---. 2 mysql mysql     8192 4月  20 02:37 performance_schema
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 private_key.pem
    -rw-r--r--. 1 mysql mysql      452 4月  20 02:37 public_key.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 server-cert.pem
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 server-key.pem
    drwxr-x---. 2 mysql mysql       28 4月  20 02:37 sys
    -rw-r-----. 1 mysql mysql 16777216 4月  21 01:18 undo_001
    -rw-r-----. 1 mysql mysql 16777216 4月  21 01:18 undo_002
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    1.1、MySQL在启动服务时会到某个目录下加载一些文件,之后在运行过程中产生的数据也会存储到这个目录下的某个文件中,该目录就称之为: 数据目录
    1.2、数据目录对应一个系统变量 datadri ,可以使用以下脚本进行查看该系统的变量值:
    mysql> show variables like '%datadir%';
    +---------------+-----------------+
    | Variable_name | Value           |
    +---------------+-----------------+
    | datadir       | /var/lib/mysql/ |
    +---------------+-----------------+
    1 row in set (8.49 sec)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    2、相关命令目录

    2.1、/usr/bin
    [root@localhost bin]# cd /usr/bin
    [root@localhost bin]# ll
    -rwxr-xr-x. 1 root root    21803088 4月  23 2021 mysql
    -rwxr-xr-x. 1 root root    19927672 4月  23 2021 mysqladmin
    -rwxr-xr-x. 1 root root    26640440 4月  23 2021 mysqlbinlog
    -rwxr-xr-x. 1 root root    20210632 4月  23 2021 mysqlcheck
    -rwxr-xr-x. 1 root root     5159528 4月  23 2021 mysql_config_editor
    -rwxr-xr-x. 1 root root        4368 4月  23 2021 mysqld_pre_systemd
    -rwxr-xr-x. 1 root root    20429552 4月  23 2021 mysqldump
    -rwxr-xr-x. 1 root root        7669 4月  23 2021 mysqldumpslow
    -rwxr-xr-x. 1 root root    19901616 4月  23 2021 mysqlimport
    -rwxr-xr-x. 1 root root    22543408 4月  23 2021 mysql_migrate_keyring
    -rwxr-xr-x. 1 root root    33337088 4月  23 2021 mysqlpump
    -rwxr-xr-x. 1 root root    19856088 4月  23 2021 mysql_secure_installation
    -rwxr-xr-x. 1 root root    19881344 4月  23 2021 mysqlshow
    -rwxr-xr-x. 1 root root    19998824 4月  23 2021 mysqlslap
    -rwxr-xr-x. 1 root root     5548144 4月  23 2021 mysql_ssl_rsa_setup
    -rwxr-xr-x. 1 root root     4024800 4月  23 2021 mysql_tzinfo_to_sql
    -rwxr-xr-x. 1 root root    22682368 4月  23 2021 mysql_upgrade
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    2.2、/usr/sbin
    [root@localhost bin]# cd /usr/sbin
    [root@localhost sbin]# ll
    -rwxr-xr-x. 1 root root 986706656 4月  23 2021 mysqld
    -rwxr-xr-x. 1 root root 674354040 4月  23 2021 mysqld-debug
    
    • 1
    • 2
    • 3
    • 4
    2.3、安装目录下的 bin 目录。里面存储了许多关于控制客户端和服务器程序的命令(可执行文件等),而 数据目录 是用来存储MySQL在运行过程中产生的数据。

    3、配置文件目录 /usr/share/mysql-8.0(命令及配置文件),/etc/mysql

    [root@localhost sbin]# cd /usr/share/mysql-8.0
    [root@localhost mysql-8.0]# ll
    总用量 976
    drwxr-xr-x. 2 root root     24 4月  20 02:12 bulgarian
    drwxr-xr-x. 2 root root   4096 4月  20 02:12 charsets
    drwxr-xr-x. 2 root root     24 4月  20 02:12 czech
    drwxr-xr-x. 2 root root     24 4月  20 02:12 danish
    -rw-r--r--. 1 root root  25575 4月  23 2021 dictionary.txt
    drwxr-xr-x. 2 root root     24 4月  20 02:12 dutch
    drwxr-xr-x. 2 root root     24 4月  20 02:12 english
    drwxr-xr-x. 2 root root     24 4月  20 02:12 estonian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 french
    drwxr-xr-x. 2 root root     24 4月  20 02:12 german
    drwxr-xr-x. 2 root root     24 4月  20 02:12 greek
    drwxr-xr-x. 2 root root     24 4月  20 02:12 hungarian
    -rw-r--r--. 1 root root   3999 4月  23 2021 innodb_memcached_config.sql
    -rw-r--r--. 1 root root   2216 4月  23 2021 install_rewriter.sql
    drwxr-xr-x. 2 root root     24 4月  20 02:12 italian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 japanese
    drwxr-xr-x. 2 root root     24 4月  20 02:12 korean
    -rw-r--r--. 1 root root 608148 4月  23 2021 messages_to_clients.txt
    -rw-r--r--. 1 root root 339567 4月  23 2021 messages_to_error_log.txt
    -rw-r--r--. 1 root root   1977 4月  23 2021 mysql-log-rotate
    drwxr-xr-x. 2 root root     24 4月  20 02:12 norwegian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 norwegian-ny
    drwxr-xr-x. 2 root root     24 4月  20 02:12 polish
    drwxr-xr-x. 2 root root     24 4月  20 02:12 portuguese
    drwxr-xr-x. 2 root root     24 4月  20 02:12 romanian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 russian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 serbian
    drwxr-xr-x. 2 root root     24 4月  20 02:12 slovak
    drwxr-xr-x. 2 root root     24 4月  20 02:12 spanish
    drwxr-xr-x. 2 root root     24 4月  20 02:12 swedish
    drwxr-xr-x. 2 root root     24 4月  20 02:12 ukrainian
    -rw-r--r--. 1 root root   1248 4月  23 2021 uninstall_rewriter.sql
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    [root@localhost mysql-8.0]# cd /etc
    [root@localhost etc]# ll
    -rw-r--r--.  1 root root     1243 4月  23 2021 my.cnf
    drwxr-xr-x.  2 root root        6 4月  23 2021 my.cnf.d
    
    • 1
    • 2
    • 3
    • 4

    二、数据库和文件系统的关系

    像相关存储引擎数据 存储在文件系统上,把用来管理磁盘的结构称为 文件系统

    1、查看默认数据库

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (16.88 sec)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • mysql 数据库:存储用户信息和权限信息,一些存储过程,事件定义信息,运行过程产生日志信息,相关帮助信息和时区信息等。
    • information_schema数据库:存储MySQL服务器 维护的其他所有数据库信息,如:表、视图、触发器、索引等,即相关元数据,提供以innodb_sys开头的表,用于表示内部系统表。
    mysql> use information_schema;
    Database changed
    mysql> show tables like 'INNODB_SYS%';
    Empty set (0.01 sec)
    
    • 1
    • 2
    • 3
    • 4
    • performance_schema 数据库:用来存储 运行过程中的 状态信息,可以 监控MySQL服务的各类性能指标。例如:最近执行了那些语句,执行语句花费多少时间,内存使用等
    • sys 数据库:主要时通过 视图 ,将 information_schemaperformance_schema 结合起来,帮助系统管理人员和开发人员监控MySQL的技术性能。

    2、数据库在文件中的表示

    2.1、在 数据目录 下创建一个和数据库名同名的目录
    2.2、在与 数据库同名 的子目录中创建一个 db.opt 的文件(MySQL 5.7),该文件中包含 该数据库各种属性,如字符集、比较规则等。
    • MySQL 5.7 下目录结构如下:
    [root@rqtanc rqtanc]# cd  /root
    [root@rqtanc ~]# cd /var/lib/mysql
    [root@rqtanc mysql]# ll
    总用量 122952
    -rw-r-----. 1 mysql mysql       56 4月  20 08:58 auto.cnf
    -rw-------. 1 mysql mysql     1676 4月  20 08:58 ca-key.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 08:58 ca.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 08:58 client-cert.pem
    -rw-------. 1 mysql mysql     1680 4月  20 08:58 client-key.pem
    drwxr-x---. 2 mysql mysql       56 4月  20 09:44 db1
    -rw-r-----. 1 mysql mysql      358 4月  21 02:22 ib_buffer_pool
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:20 ibdata1
    -rw-r-----. 1 mysql mysql 50331648 4月  22 06:20 ib_logfile0
    -rw-r-----. 1 mysql mysql 50331648 4月  20 08:58 ib_logfile1
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:08 ibtmp1
    drwxr-x---. 2 mysql mysql     4096 4月  20 08:58 mysql
    srwxrwxrwx. 1 mysql mysql        0 4月  22 06:08 mysql.sock
    -rw-------. 1 mysql mysql        5 4月  22 06:08 mysql.sock.lock
    drwxr-x---. 2 mysql mysql     8192 4月  20 08:58 performance_schema
    -rw-------. 1 mysql mysql     1680 4月  20 08:58 private_key.pem
    -rw-r--r--. 1 mysql mysql      452 4月  20 08:58 public_key.pem
    drwxr-x---. 2 mysql mysql       66 4月  22 06:20 rqtanc
    -rw-r--r--. 1 mysql mysql     1112 4月  20 08:58 server-cert.pem
    -rw-------. 1 mysql mysql     1680 4月  20 08:58 server-key.pem
    drwxr-x---. 2 mysql mysql     8192 4月  20 08:58 sys
    [root@rqtanc mysql]# cd ./rqtanc
    [root@rqtanc rqtanc]# ll
    总用量 112
    -rw-r-----. 1 mysql mysql    67 4月  22 06:17 db.opt
    -rw-r-----. 1 mysql mysql  8586 4月  22 06:20 rqtanc_test.frm
    -rw-r-----. 1 mysql mysql 98304 4月  22 06:20 rqtanc_test.ibd
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • MySQL 8.0 下目录结构如下:
    [root@localhost ~]# cd /var/lib/mysql
    [root@localhost mysql]# ll
    总用量 188876
    -rw-r-----. 1 mysql mysql       56 4月  20 02:37 auto.cnf
    -rw-r-----. 1 mysql mysql     1756 4月  21 01:15 binlog.000001
    -rw-r-----. 1 mysql mysql      156 4月  22 06:13 binlog.000002
    -rw-r-----. 1 mysql mysql      592 4月  22 06:24 binlog.000003
    -rw-r-----. 1 mysql mysql       48 4月  22 06:13 binlog.index
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 ca-key.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 ca.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 client-cert.pem
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 client-key.pem
    -rw-r-----. 1 mysql mysql   196608 4月  22 06:24 #ib_16384_0.dblwr
    -rw-r-----. 1 mysql mysql  8585216 4月  20 02:36 #ib_16384_1.dblwr
    -rw-r-----. 1 mysql mysql     5472 4月  20 02:37 ib_buffer_pool
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:24 ibdata1
    -rw-r-----. 1 mysql mysql 50331648 4月  22 06:24 ib_logfile0
    -rw-r-----. 1 mysql mysql 50331648 4月  20 02:36 ib_logfile1
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:12 ibtmp1
    drwxr-x---. 2 mysql mysql      187 4月  22 06:12 #innodb_temp
    drwxr-x---. 2 mysql mysql      143 4月  20 02:37 mysql
    -rw-r-----. 1 mysql mysql 25165824 4月  22 06:24 mysql.ibd
    srwxrwxrwx. 1 mysql mysql        0 4月  22 06:13 mysql.sock
    -rw-------. 1 mysql mysql        5 4月  22 06:13 mysql.sock.lock
    drwxr-x---. 2 mysql mysql     8192 4月  20 02:37 performance_schema
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 private_key.pem
    -rw-r--r--. 1 mysql mysql      452 4月  20 02:37 public_key.pem
    drwxr-x---. 2 mysql mysql       29 4月  22 06:24 rqtanc
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 server-cert.pem
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 server-key.pem
    drwxr-x---. 2 mysql mysql       28 4月  20 02:37 sys
    -rw-r-----. 1 mysql mysql 16777216 4月  22 06:24 undo_001
    -rw-r-----. 1 mysql mysql 16777216 4月  22 06:24 undo_002
    [root@localhost mysql]# cd ./rqtanc
    [root@localhost rqtanc]# ll
    总用量 80
    -rw-r-----. 1 mysql mysql 114688 4月  22 06:24 rqtanc_test.ibd
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37

    3、数据表在文件系统的表示

    3.1、 每张数据表的信息可以分为以下两种:

    • 表结构的定义:即 表名,字段,字段的数据类型,相关约束,索引,字符集,比较规则等等
    • 表中的数据:数据记录

    3.2、 InnoDB存储引擎模式

    3.2.1、 表结构 : 在InnoDB从模式下,在数据目录下对应数据库子目录中创建一个专门用于 描述表结构的文件,文件名为:rqtanc_test.frm,以后缀 .frm 结尾的文件

    3.2.2、表中数据及索引
    • InnoDB存储模式下是使用 为基本单位管理存储空间,默认 的大小为 16kb
    • InnoDB存储模式下,每个索引都对应一颗B+树,该B+树的每个节点都是一个数据页数据页之间不一定是物理连续数据页之间有 双向链表 来维护这些 顺序
    • InnoDB的聚簇索引叶子节点存储了完整的用户记录,即 索引即数据,数据即索引
    3.2.2.1、系统表空间
    • 默认情况下,InnoDB存储引擎会在 数据目录 下创建一个 ibdata1 大小为 12M 的文件,该文件就是 系统表空间 在文件系统上的显示,该文件是 自拓展 文件,当超出容量时会自己增加文件大小
    • 在MySQL启动时可自定义配置 系统表空间 文件名称,路径及空间大小,如以下命令并重启MySQL服务
    [root@rqtanc ~]# vim /etc/my.cnf
    
    #添加以下信息,保存退出
    innodb_data_home_dir = /path/to/new/directory
    innodb_data_file_path = ibdata1:10M:autoextend
    
    • 1
    • 2
    • 3
    • 4
    • 5
    3.2.2.2、独立表空间
    • InnoDB存储引擎模式并不会将所有表数据存储在系统表空间下,而是会为 每一个表建立一个独立的表空间,使用 独立表空间 存储数据 (MySQL 8.0 中 表结构,数据全部存储在该文件中)如以下 .ibd 后缀文件所示:
    [root@rqtanc mysql]# cd ./rqtanc
    [root@rqtanc rqtanc]# ll
    总用量 112
    -rw-r-----. 1 mysql mysql    67 4月  22 06:17 db.opt
    -rw-r-----. 1 mysql mysql  8586 4月  22 06:20 rqtanc_test.frm
    -rw-r-----. 1 mysql mysql 98304 4月  22 06:20 rqtanc_test.ibd
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    3.2.2.3、系统表空间 与 独立表空间 的设置
    • 查看默认情况下,MySQL采用的是那种存储空间,执行以下命令:
    mysql> show variables like '%innodb_file_per_table%';
    +-----------------------+-------+
    | Variable_name         | Value |
    +-----------------------+-------+
    | innodb_file_per_table | ON    |
    +-----------------------+-------+
    1 row in set (0.35 sec)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 可以自定义设置使用 系统表空间 或 独立表空间,执行以下命令,添加内容重启MySQL服务,修改内容对已分配 表空间不起作用
    [root@rqtanc ~]# vim /etc/my.cnf
    
    #添加以下信息并保存
    innodb_file_per_table=0 
    # 0 : 表示使用系统表空间
    # 1 : 表示使用独立表空间
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 如果想将已经存在 独立表空间 的表转移系统表空间,执行以下脚本命令
    alter table rqtanc_test tablespace  innodb_system;
    
    • 1
    • 如果想将已经存在 系统表空间 的表转移独立表空间,执行以下脚本命令
    alter table rqtanc_test tablespace  innodb_file_per_table;
    
    • 1
    3.2.2.4、如何查看MySQL 8.0 中表空间存储信息,执行以下操作:
    [root@localhost ~]# cd /var/lib/mysql
    [root@localhost mysql]# ll
    总用量 188876
    -rw-r-----. 1 mysql mysql       56 4月  20 02:37 auto.cnf
    -rw-r-----. 1 mysql mysql     1756 4月  21 01:15 binlog.000001
    -rw-r-----. 1 mysql mysql      156 4月  22 06:13 binlog.000002
    -rw-r-----. 1 mysql mysql      592 4月  22 06:24 binlog.000003
    -rw-r-----. 1 mysql mysql       48 4月  22 06:13 binlog.index
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 ca-key.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 ca.pem
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 client-cert.pem
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 client-key.pem
    -rw-r-----. 1 mysql mysql   196608 4月  22 06:24 #ib_16384_0.dblwr
    -rw-r-----. 1 mysql mysql  8585216 4月  20 02:36 #ib_16384_1.dblwr
    -rw-r-----. 1 mysql mysql     5472 4月  20 02:37 ib_buffer_pool
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:24 ibdata1
    -rw-r-----. 1 mysql mysql 50331648 4月  22 06:24 ib_logfile0
    -rw-r-----. 1 mysql mysql 50331648 4月  20 02:36 ib_logfile1
    -rw-r-----. 1 mysql mysql 12582912 4月  22 06:12 ibtmp1
    drwxr-x---. 2 mysql mysql      187 4月  22 06:12 #innodb_temp
    drwxr-x---. 2 mysql mysql      143 4月  20 02:37 mysql
    -rw-r-----. 1 mysql mysql 25165824 4月  22 06:24 mysql.ibd
    srwxrwxrwx. 1 mysql mysql        0 4月  22 06:13 mysql.sock
    -rw-------. 1 mysql mysql        5 4月  22 06:13 mysql.sock.lock
    drwxr-x---. 2 mysql mysql     8192 4月  20 02:37 performance_schema
    -rw-------. 1 mysql mysql     1676 4月  20 02:37 private_key.pem
    -rw-r--r--. 1 mysql mysql      452 4月  20 02:37 public_key.pem
    drwxr-x---. 2 mysql mysql       29 4月  22 06:24 rqtanc
    -rw-r--r--. 1 mysql mysql     1112 4月  20 02:37 server-cert.pem
    -rw-------. 1 mysql mysql     1680 4月  20 02:37 server-key.pem
    drwxr-x---. 2 mysql mysql       28 4月  20 02:37 sys
    -rw-r-----. 1 mysql mysql 16777216 4月  22 06:24 undo_001
    -rw-r-----. 1 mysql mysql 16777216 4月  22 06:24 undo_002
    [root@localhost mysql]# cd ./rqtanc
    [root@localhost rqtanc]# ll
    总用量 80
    -rw-r-----. 1 mysql mysql 114688 4月  22 06:24 rqtanc_test.ibd
    [root@localhost rqtanc]# ibd2sdi --dump-file=rqtanc_test.txt rqtanc_test.ibd
    [root@localhost rqtanc]# ll
    总用量 92
    -rw-r-----. 1 mysql mysql 114688 4月  22 06:24 rqtanc_test.ibd
    -rw-------. 1 root  root   11134 4月  22 07:47 rqtanc_test.txt
    [root@localhost rqtanc]# vim ./rqtanc_test.txt
    
    #展示为以下内容
    ["ibd2sdi"
    ,
    {
    	"type": 1,
    	"id": 360,
    	"object":
    		{
        "mysqld_version_id": 80025,
        "dd_version": 80023,
        "sdi_version": 80019,
        "dd_object_type": "Table",
        "dd_object": {
            "name": "rqtanc_test",
            "mysql_version_id": 80025,
            "created": 20240422132410,
            "last_altered": 20240422132410,
            "hidden": 1,
            "options": "avg_row_length=0;encrypt_type=N;key_block_size=0;keys_disabled=0;pack_record=1;stats_auto_recalc=0;stats_sample_pages=0;",
            "columns": [
                {
                    "name": "id",
                    "type": 4,
                    "is_nullable": true,
                    "is_zerofill": false,
                    "is_unsigned": false,
                    "is_auto_increment": false,
                    "is_virtual": false,
                    "hidden": 1,
                    "ordinal_position": 1,
                    "char_length": 11,
                    "numeric_precision": 10,
                    "numeric_scale": 0,
                    "numeric_scale_null": false,
                    "datetime_precision": 0,
                    "datetime_precision_null": 1,
                    "has_no_default": false,
                    "default_value_null": true,
                    "srs_id_null": true,
                    "srs_id": 0,
                    "default_value": "",
                    "default_value_utf8_null": true,
                    "default_value_utf8": "",
                    "default_option": "",
                    "update_option": "",
                    "comment": "",
                    "generation_expression": "",
                    "generation_expression_utf8": "",
                    "options": "interval_count=0;",
                    "se_private_data": "table_id=1061;",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "column_key": 1,
                    "column_type_utf8": "int",
                    "elements": [],
                    "collation_id": 255,
                    "is_explicit_collation": false
                },
                {
                    "name": "name",
                    "type": 16,
                    "is_nullable": true,
                    "is_zerofill": false,
                    "is_unsigned": false,
                    "is_auto_increment": false,
                    "is_virtual": false,
                    "hidden": 1,
                    "ordinal_position": 2,
                    "char_length": 60,
                    "numeric_precision": 0,
                    "numeric_scale": 0,
                    "numeric_scale_null": true,
                    "datetime_precision": 0,
                    "datetime_precision_null": 1,
                    "has_no_default": false,
                    "default_value_null": true,
                    "srs_id_null": true,
                    "srs_id": 0,
                    "default_value": "",
                    "default_value_utf8_null": true,
                    "default_value_utf8": "",
                    "default_option": "",
                    "update_option": "",
                    "comment": "",
                    "generation_expression": "",
                    "generation_expression_utf8": "",
                    "options": "interval_count=0;",
                    "se_private_data": "table_id=1061;",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "column_key": 1,
                    "column_type_utf8": "varchar(15)",
                    "elements": [],
                    "collation_id": 255,
                    "is_explicit_collation": false
                },
                {
                    "name": "DB_ROW_ID",
                    "type": 10,
                    "is_nullable": false,
                    "is_zerofill": false,
                    "is_unsigned": false,
                    "is_auto_increment": false,
                    "is_virtual": false,
                    "hidden": 2,
                    "ordinal_position": 3,
                    "char_length": 6,
                    "numeric_precision": 0,
                    "numeric_scale": 0,
                    "numeric_scale_null": true,
                    "datetime_precision": 0,
                    "datetime_precision_null": 1,
                    "has_no_default": false,
                    "default_value_null": true,
                    "srs_id_null": true,
                    "srs_id": 0,
                    "default_value": "",
                    "default_value_utf8_null": true,
                    "default_value_utf8": "",
                    "default_option": "",
                    "update_option": "",
                    "comment": "",
                    "generation_expression": "",
                    "generation_expression_utf8": "",
                    "options": "",
                    "se_private_data": "table_id=1061;",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "column_key": 1,
                    "column_type_utf8": "",
                    "elements": [],
                    "collation_id": 63,
                    "is_explicit_collation": false
                },
                {
                    "name": "DB_TRX_ID",
                    "type": 10,
                    "is_nullable": false,
                    "is_zerofill": false,
                    "is_unsigned": false,
                    "is_auto_increment": false,
                    "is_virtual": false,
                    "hidden": 2,
                    "ordinal_position": 4,
                    "char_length": 6,
                    "numeric_precision": 0,
                    "numeric_scale": 0,
                    "numeric_scale_null": true,
                    "datetime_precision": 0,
                    "datetime_precision_null": 1,
                    "has_no_default": false,
                    "default_value_null": true,
                    "srs_id_null": true,
                    "srs_id": 0,
                    "default_value": "",
                    "default_value_utf8_null": true,
                    "default_value_utf8": "",
                    "default_option": "",
                    "update_option": "",
                    "comment": "",
                    "generation_expression": "",
                    "generation_expression_utf8": "",
                    "options": "",
                    "se_private_data": "table_id=1061;",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "column_key": 1,
                    "column_type_utf8": "",
                    "elements": [],
                    "collation_id": 63,
                    "is_explicit_collation": false
                },
                {
                    "name": "DB_ROLL_PTR",
                    "type": 9,
                    "is_nullable": false,
                    "is_zerofill": false,
                    "is_unsigned": false,
                    "is_auto_increment": false,
                    "is_virtual": false,
                    "hidden": 2,
                    "ordinal_position": 5,
                    "char_length": 7,
                    "numeric_precision": 0,
                    "numeric_scale": 0,
                    "numeric_scale_null": true,
                    "datetime_precision": 0,
                    "datetime_precision_null": 1,
                    "has_no_default": false,
                    "default_value_null": true,
                    "srs_id_null": true,
                    "srs_id": 0,
                    "default_value": "",
                    "default_value_utf8_null": true,
                    "default_value_utf8": "",
                    "default_option": "",
                    "update_option": "",
                    "comment": "",
                    "generation_expression": "",
                    "generation_expression_utf8": "",
                    "options": "",
                    "se_private_data": "table_id=1061;",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "column_key": 1,
                    "column_type_utf8": "",
                    "elements": [],
                    "collation_id": 63,
                    "is_explicit_collation": false
                }
            ],
            "schema_ref": "rqtanc",
            "se_private_id": 1061,
            "engine": "InnoDB",
            "last_checked_for_upgrade_version_id": 0,
            "comment": "",
            "se_private_data": "",
            "engine_attribute": "",
            "secondary_engine_attribute": "",
            "row_format": 2,
            "partition_type": 0,
            "partition_expression": "",
            "partition_expression_utf8": "",
            "default_partitioning": 0,
            "subpartition_type": 0,
            "subpartition_expression": "",
            "subpartition_expression_utf8": "",
            "default_subpartitioning": 0,
            "indexes": [
                {
                    "name": "PRIMARY",
                    "hidden": true,
                    "is_generated": false,
                    "ordinal_position": 1,
                    "comment": "",
                    "options": "",
                    "se_private_data": "id=150;root=4;space_id=2;table_id=1061;trx_id=2570;",
                    "type": 2,
                    "algorithm": 2,
                    "is_algorithm_explicit": false,
                    "is_visible": true,
                    "engine": "InnoDB",
                    "engine_attribute": "",
                    "secondary_engine_attribute": "",
                    "elements": [
                        {
                            "ordinal_position": 1,
                            "length": 4294967295,
                            "order": 2,
                            "hidden": true,
                            "column_opx": 2
                        },
                        {
                            "ordinal_position": 2,
                            "length": 4294967295,
                            "order": 2,
                            "hidden": true,
                            "column_opx": 3
                        },
                        {
                            "ordinal_position": 3,
                            "length": 4294967295,
                            "order": 2,
                            "hidden": true,
                            "column_opx": 4
                        },
                        {
                            "ordinal_position": 4,
                            "length": 4294967295,
                            "order": 2,
                            "hidden": true,
                            "column_opx": 0
                        },
                        {
                            "ordinal_position": 5,
                            "length": 4294967295,
                            "order": 2,
                            "hidden": true,
                            "column_opx": 1
                        }
                    ],
                    "tablespace_ref": "rqtanc/rqtanc_test"
                }
            ],
            "foreign_keys": [],
            "check_constraints": [],
            "partitions": [],
            "collation_id": 255
        }
    }
    }
    ,
    {
    	"type": 2,
    	"id": 7,
    	"object":
    		{
        "mysqld_version_id": 80025,
        "dd_version": 80023,
        "sdi_version": 80019,
        "dd_object_type": "Tablespace",
        "dd_object": {
            "name": "rqtanc/rqtanc_test",
            "comment": "",
            "options": "autoextend_size=0;encryption=N;",
            "se_private_data": "flags=16417;id=2;server_version=80025;space_version=1;state=normal;",
            "engine": "InnoDB",
            "engine_attribute": "",
            "files": [
                {
                    "ordinal_position": 1,
                    "filename": "./rqtanc/rqtanc_test.ibd",
                    "se_private_data": "id=2;"
                }
            ]
        }
    }
    }
    ]
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364

    3.3、MyISAM存储引擎模式

    3.3.1、表结构 : 与INNODB 存储引擎模式一致。

    3.3.2、表中数据及索引:
    • 在MyISAM中的索引全部都是 二级索引 ,该存储引擎模式下 数据和索引 是分开存放 的。
    • 该引擎模式下会为表创建 三个文件,具体如下
      .frm 后缀文件 (MySQL 5.7) , .sdi 后缀文件 (MySQL 8.0 ): 存储表结构
      .MYD 后缀文件 : 存储数据
      .MYI 后缀文件 : 存储索引
  • 相关阅读:
    C++设计模式-创建型设计模式:原型模式
    SpringData Hibernate JPA 使用案例 案例 (一)
    云仓酒庄北京朝阳区旗舰店发布活动盛况:红酒品鉴沙龙共筑美好
    web前端期末大作业 html+css+javascript汽车介绍网页设计实例 企业网站制作(带报告3490字)
    vs code 工具HTML、css、javaScript、Vue、等代码插件安装
    如何用servlet写注册登录页面?
    C++ string模拟实现
    nacos 问题
    武汉新时标文化传媒有限公司视频引流推广
    黑白简约个人网页制作 大学生个人网页设计模板 学生个人博客网页成品 简单个人网站作品下载 静态HTML CSS个人网页作业源代码
  • 原文地址:https://blog.csdn.net/badBoy_badMan/article/details/138050081