MySQL data directory

source

Several MySQL storage engines such as InnoDB and MyISAM all the data stored on disk, while our operating system is to manage the disk through the file system, it can be said that these are the storage engine tables are stored in the file system , and we read and write data to the file by the operating system.

definition

MySQL data directory server to store data during operation generated heavy, and will load some files from this directory when the server starts. The installation directory, the installation directory stores a lot of control server and client commands.

structure

By statement SHOW VARIABLES LIKE 'datadir'; you can view the data directory address.

The following picture shows the contents of the data directory, INFORMATION_SCHEMA special, not using the appropriate database directory

Known data directory location, our database will be created in the folder below creates a subdirectory with the same name, and create a file named db.opt in this subdirectory, this file contains the various attributes of the database, such as character set / compare rules

The picture shows the following contents tcc directory database that contains definitions and table data table structure

Different storage engines to store data in different tables
  • InnoDB
    • Page is the basic unit of storage management

    • Corresponding to a B + tree index, B + tree, each node corresponds to a page of data

    • InnoDB table space proposed concept / file space on the file system corresponds to one or more real files, our data is stored in the table some of the pages in a table space

      • Table space: the data stored in the directory named ibdata1, is a self-expanding file, which may be modified by modifying the position of the size of the configuration file; only one system tablespace in a MySQL server, version between MySQL5.5.7-5.6.6 , the default data in the table stored in the system table space
      • A separate table space: After MySQL5.6.6 version does not default InnoDB table data (data + index) is stored in the system table space but every single table to create a separate table space, each database is stored in the directory is to .ibd extension name;
      • Innodb_file_per_table = 0 can be configured into the system table Confucius data storage space, a space is stored in a separate table, if you want to migrate to the original system data / space is available a separate table ALTER TABLE statement table TABLESPACE [=] innodb_system; system table only some of the system data storage space, a separate table space to store the data in this table only
      • Other types of table space .......
  • MyISAM
    • MyISAM index all secondary index, and the index and the data are stored separately, the use of different files to store data files and index files
    • No space table stores table data corresponding to the subdirectory database representative .MYD data file, the index file on behalf .MYI

 

view

MySQL view in fact, is a virtual table, so no need to store the actual data storage view, as long as the storage structure to .frm file is stored in the database under the corresponding directory; no .frm file after version 8.0

Other files

Under the data directory also store some other files to better run the program

  • File server process
  • Server log files
  • Default / automatic generation of SSL and RSA certificate and key files

 

InnoDB table space

  • A separate table space structure
  • Table space structure

Table space is divided into a plurality of continuous extent, by default each area consists of 64 pages, each 256 divisions into one group, type a few pages the beginning of each group is fixed.

Guess you like

Origin www.cnblogs.com/hangzhi/p/11100686.html