Using Symbolic Links
728
These table symlink operations are not supported:
•
ALTER TABLE
ignores the
DATA DIRECTORY
and
INDEX DIRECTORY
table options.
•
BACKUP TABLE
and
RESTORE TABLE
do not respect symbolic links.
• As indicated previously, only the data and index files can be symbolic links. The
.frm
file must
never be a symbolic link. Attempting to do this (for example, to make one table name a synonym
for another) produces incorrect results. Suppose that you have a database
db1
under the MySQL
data directory, a table
tbl1
in this database, and in the
db1
directory you make a symlink
tbl2
that
points to
tbl1
:
shell>
cd /path/to/datadir/db1
shell>
ln -s tbl1.frm tbl2.frm
shell>
ln -s tbl1.MYD tbl2.MYD
shell>
ln -s tbl1.MYI tbl2.MYI
Problems result if one thread reads
db1.tbl1
and another thread updates
db1.tbl2
:
• The query cache is “fooled” (it has no way of knowing that
tbl1
has not been updated, so it
returns outdated results).
•
ALTER
statements on
tbl2
fail.
8.9.6.3. Using Symbolic Links for Databases on Windows
On Windows, symbolic links can be used for database directories. This enables you to put a database
directory at a different location (for example, on a different disk) by setting up a symbolic link to it. Use
of database symlinks on Windows is similar to their use on Unix, although the procedure for setting up
the link differs.
Suppose that you want to place the database directory for a database named
mydb
at
D:\data\mydb
.
To do this, create a symbolic link in the MySQL data directory that points to
D:\data\mydb
. However,
before creating the symbolic link, make sure that the
D:\data\mydb
directory exists by creating it if
necessary. If you already have a database directory named
mydb
in the data directory, move it to
D:
\data
. Otherwise, the symbolic link will be ineffective. To avoid problems, make sure that the server is
not running when you move the database directory.
On Windows, create a symbolic link to a MySQL database by creating a
.sym
file in the data directory
that contains the path to the destination directory. The file should be named
db_name.sym
, where
db_name
is the database name.
Support for database symbolic links on Windows using
.sym
files is enabled by default. If you do not
need
.sym
file symbolic links, you can disable support for them by starting
mysqld
with the
--skip-
symbolic-links
[421]
option. To determine whether your system supports
.sym
file symbolic links,
check the value of the
have_symlink
[455]
system variable using this statement:
SHOW VARIABLES LIKE 'have_symlink';
To create a
.sym
file symlink, use this procedure:
1. Change location into the data directory:
C:\>
cd \path\to\datadir
2. In the data directory, create a text file named
mydb.sym
that contains this path name:
D:\data
\mydb\
Note
The path name to the new database and tables should be absolute. If you
specify a relative path, the location will be relative to the
mydb.sym
file.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...