You can move tables and databases 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.
If MySQL notices that a table is
symbolically linked, it will resolve the symlink and use the table it points to
instead. This works on all systems that support the realpath() call (at least
Linux and Solaris support realpath())! On systems that don't support
realpath(), you should not access the table through the real path and through
the symlink at the same time! If you do, the table will be inconsistent after
any update.
MySQL doesn't that you link one
directory to multiple databases. Replacing a database directory with a symbolic
link will work fine as long as you don't make a symbolic link between
databases. Suppose you have a database db1 under the MySQL data directory, and
then make a symlink db2 that points to db1:
shell> cd /path/to/datadir
shell> ln -s db1 db2
Now, for any table tbl_a in db1, there
also appears to be a table tbl_a in db2. If one thread updates db1.tbl_a and
another thread updates db2.tbl_a, there will be problems.
If you really need this, you must
change the following code in `mysys/mf_format.c':
if (flag & 32 ||
(!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
to
if (1)
On Windows you can use internal symbolic
links to directories by compiling MySQL with -DUSE_SYMDIR. This allows you to
put different databases on different disks.
No comments:
Post a Comment