Search the MySQL manual:

5.6.1.1 Using Symbolic Links for Databases

The way to symlink a database is to first create a directory on some disk where you have free space and then create a symlink to it from the MySQL database directory.

shell> mkdir /dr1/databases/test
shell> ln -s /dr1/databases/test mysqld-datadir

MySQL doesn't support 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. See section 2.6.1.5 Distributing Data Across Different Disks on Windows.

User Comments

Posted by [name withheld] on Tuesday March 4 2003, @7:25am[Delete] [Edit]

When writing symbolic link files from VB, don't use the Open for Input/Write statements, as that puts quotation marks around the path string, which MySQL rejects. The Open for Binary/Put statements do work.

Posted by [name withheld] on Tuesday March 4 2003, @7:34am[Delete] [Edit]

A clarification, which should be obvious: Open for Output/Write doesn't work for symbolic links. I said Open for Input. It's early.

Add your own comment.