After many systems are officially launched, as the amount of data increases, the available space in the data directory will become smaller and smaller, leading to security risks. For such problems, you can take different measures based on different situations.
For MyISAM engine tables, when creating tables, you can use the following options to specify the data directory And index directory to store them in different disk spaces. By default, they are stored in the data directory.
For example
Create Table T1 (ID int, name varchar (10) data directory = '/var/lib/MySQL/data' index directory ='/var/lib/MySQL/Index ';
Can these paths be changed at any time during use? The answer is no,
Alter table T1 index directory = '/var/lib/MySQL/data' ------------------------------ is it successful?
In this case, if the table has been created, you can also move the data files and index files of the table to a sufficient partition on the disk, and then create a symbolic link in the original file. Of course, you must stop or lock the table before the music video to prevent table changes.
**************************************** *********************************
For InnoDB tables that store engines, data files and index files are stored together, so they cannot be separated. When disk space is insufficient, you can add a new data file on a disk with sufficient space. The specific implementation method is to add this file to the innodb_data_file_path parameter, and write the path to the absolute path of the new disk, for example, if the space in/home is insufficient and you want to add a file under home1 that can automatically expand the data, you can write the parameter as follows:
Innodb_data_file_path =/home/iddata1: 2000 m;/home1/ibdata2: 2000 m: autoextend
After modifying the parameters, restart the database to take effect.