您可以将数据库或表从数据库目录移动到其他位置,并用指向新位置的符号链接替换它们。例如,您可能想这样做,以将数据库移动到拥有更多可用空间的文件系统,或者通过将表分散到不同的磁盘上来提高系统速度。You can move databases or tables from the database directory to other locations and replace them with symbolic links to the new locations. You might want to do this, for example, to move a database to a file system with more free space or increase the speed of your system by spreading your tables to different disks.
对于 InnoDB 表,请使用 DATA
DIRECTORY 语句的 CREATE
TABLE 子句,而不是使用符号链接,如 第 17.6.1.2 节,“在外部创建表” 所述。这项新功能是一种受支持的、跨平台的技术。For InnoDB tables, use the DATA
DIRECTORY clause of the CREATE
TABLE statement instead of symbolic links, as
explained in Section 17.6.1.2, “Creating Tables Externally”.
This new feature is a supported, cross-platform technique.
推荐的方法是将整个数据库目录符号链接到不同的磁盘。仅在万不得已的情况下才为 MyISAM 表创建符号链接。The recommended way to do this is to symlink entire database
directories to a different disk. Symlink
MyISAM tables only as a last resort.
要确定您的数据目录的位置,请使用以下语句:To determine the location of your data directory, use this statement:
SHOW VARIABLES LIKE 'datadir';