Using Symbolic Links for Tables on Unix
Do not symlink tables on systems that do not have a fully operational realpath() call. (Linux and Solaris support realpath()). Check whether your system supports symbolic links by issuing a SHOW VARIABLES LIKE 'have_symlink' statement.
Symlinks are fully supported only for MyISAM tables. For files used by tables for other storage engines, you may get strange problems if you try to use symbolic links.
The handling of symbolic links for MyISAM tables works as follows:
- In the data directory, you always have the table format (
.frm) file, the data (.MYD) file, and the index (.MYI) file. The data file and index file can be moved elsewhere and replaced in the data directory by symlinks. The format file cannot. - You can symlink the data file and the index file independently to different directories.
- You can instruct a running MariaDB server to perform the symlinking by using the
DATA DIRECTORYandINDEX DIRECTORYoptions toCREATE TABLE. See , "CREATE TABLESyntax". Alternatively, symlinking can be accomplished manually from the command line usingln -sif mysqld is not running.NoteThe path used with either or both of the
DATA DIRECTORYandINDEX DIRECTORYoptions may not include the MariaDBdatadirectory. (Bug #32167) - myisamchk does not replace a symlink with the data file or index file. It works directly on the file to which the symlink points. Any temporary files are created in the directory where the data file or index file is located. The same is true for the
ALTER TABLE,OPTIMIZE TABLE, andREPAIR TABLEstatements. - Note
When you drop a table that is using symlinks, both the symlink and the file to which the symlink points are dropped. This is an extremely good reason not to run mysqld as the system
rootor permit system users to have write access to MariaDB database directories. - If you rename a table with
ALTER TABLE ... RENAMEorRENAME TABLEand you do not move the table to another database, the symlinks in the database directory are renamed to the new names and the data file and index file are renamed accordingly. - If you use
ALTER TABLE ... RENAMEorRENAME TABLEto move a table to another database, the table is moved to the other database directory. If the table name changed, the symlinks in the new database directory are renamed to the new names and the data file and index file are renamed accordingly. - If you are not using symlinks, use the
--skip-symbolic-linksoption to mysqld to ensure that no one can use mysqld to drop or rename a file outside of the data directory.
Table symlink operations that are not yet supported:
ALTER TABLEignores theDATA DIRECTORYandINDEX DIRECTORYtable options.- The
.frmfile must never be a symbolic link (as indicated previously, only the data and index files can be symbolic links). Attempting to do this (for example, to make synonyms) produces incorrect results. Suppose that you have a databasedb1under the MariaDB data directory, a tabletbl1in this database, and in thedb1directory you make a symlinktbl2that points totbl1:shell>
cdshell>/path/to/datadir/db1ln -s tbl1.frm tbl2.frmshell>ln -s tbl1.MYD tbl2.MYDshell>ln -s tbl1.MYI tbl2.MYIProblems result if one thread reads
db1.tbl1and another thread updatesdb1.tbl2:- The query cache is "fooled" (it has no way of knowing that
tbl1has not been updated, so it returns outdated results). ALTERstatements ontbl2fail.
Retornar
- The query cache is "fooled" (it has no way of knowing that