Creating file-per-table tablespaces outside the data directory

一、 Data Directory

1、应对情况

当数据库所在空间不足的时候,通过新增一块磁盘,如何将新建的表放到新建磁盘,就可以用到MySQL的Data Directory

2、使用Data Directory条件

1)InnoDB引擎

2)开启innodb_file_per_table或者在建表时加上此参数

二、操作测试

1、查看数据库版本与表空间目录

MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory_ide

2、操作系统新建存储目录

MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory_建表_02

3、建表测试

MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory_文件目录_03

4、查看新建的表

1)表的定义文件任然保存在老的数据文件目录

MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory_数据_04

2)表的tablespace在新的数据文件目录

MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory_ide_05