Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.8Mb
PDF (RPM) - 36.4Mb
HTML Download (TGZ) - 9.8Mb
HTML Download (Zip) - 9.9Mb
HTML Download (RPM) - 8.6Mb
Man Pages (TGZ) - 209.5Kb
Man Pages (Zip) - 318.7Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Using Symbolic Links for Databases on Unix Using Symbolic Links for Databases on Unix

On Unix, the way to symlink a database is first to create a directory on some disk where you have free space and then to create a soft link to it from the MySQL data directory.

shell> mkdir /dr1/databases/test
shell> ln -s /dr1/databases/test /path/to/datadir

MySQL does not support linking one directory to multiple databases. Replacing a database directory with a symbolic link works as long as you do not make a symbolic link between databases. Suppose that 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

The result is that, for any table tbl_a in db1, there also appears to be a table tbl_a in db2. If one client updates db1.tbl_a and another client updates db2.tbl_a, problems are likely to occur.

User Comments
  Posted by on March 4, 2003
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 on March 4, 2003
A clarification, which should be obvious: Open for Output/Write doesn't work for symbolic links. I said Open for Input. It's early.
  Posted by Nilesh G on January 26, 2008
If you want quotas for users, setup system quotas for the group in which the user is, then create a separate databases directory in his home directory with permission mysql:usergroup and permission 0755

Then move the databases to that directory and create symbolic links to the original mysql datadir.
  Posted by Marcus Bointon on September 8, 2008
If you're symlinking to databases outside /var/lib/mysql and you're getting unexpected "(errno: 13)" (permission denied) errors, check your MySQL settings for AppArmor (particularly on Ubuntu as of 8.04) or SELinux. Specifically, make sure your new path is listed in /etc/apparmor.d/usr.sbin.mysqld then restart apparmor.
  Posted by Nico Kadel-Garcia on February 17, 2015
These days, also check SELinux permissions. See for a walkthrough.
Sign Up Login You must be logged in to post a comment.