I have been migrating an older server running apache2 + mysql under ubuntu to a new server running debian (wheezy). The migration works fine while the databases are storted localy (in our case /srv/mysql), but when i try to move them to our centralized storage running NFS and creating symbolic links to the moved files mysql does not seem to find the databases at all. I get no errors from mysql, it just seems to believe there is no such database.

This is the layout of /srv/mysql (few examples):

user@server:/srv/mysql# ls -al
total 135440
drwxr-xr-x 50 mysql mysql      4096 May 22 09:59 .
drwxr-xr-x  7 root  root       4096 May 22 09:59 ..
drwxrwx---  2 mysql mysql      4096 May 21 20:13 database_dir_1
drwx------  2 mysql mysql      4096 May 21 19:07 database_dir_2
drwxrwx---  2 mysql mysql      4096 May 21 20:15 database_dir_3
drwx------  2 mysql mysql      4096 May 21 20:15 database_dir_4
drwxrwx---  2 mysql mysql      4096 May 21 20:15 database_dir_5

How i create symbolic links:

mv /srv/mysql/database_dir_1 /mnt/centralstorage/customer1/db/database_dir_1
ln -s /mnt/centralstorage/customer1/db/database_dir_1 /srv/mysql/database_dir_1
ls -al /srv/mysql/
drwxrwx---  1 root root      28 May 21 20:13 database_dir_1 -> /mnt/centralstorage/customer1/db/database_dir_1

After this mysql no longer sees database_dir_1, but it is fully browseable from cli.

The mounts for /mnt/centralstorage looks like this: on /mnt/centralstorage/ type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=,mountvers=3,mountport=49535,mountproto=udp,local_lock=none,addr=

And the export on the central server:


(all names and such have been changed)

Anyone see any issues with the setup?

With regards, FrontSlash


After some help from @Fox the problem seems to be the NFS connection. Does anyone see any issues in the nfs configuration i posted above? If you need more information i will post it.


Did a quick test, exportet a new folder on the NFS server, /srv/temp, with the same settings as the other two exports.

Mounted this on the sql server with fstab instead of the previous startup-script that ran.

The script simply did a

mount $host:$dir $mnt_dir/$mmount

Which produced this mount: on /mnt/centralstorage/ type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=,mountvers=3,mountport=49535,mountproto=udp,local_lock=none,addr=

The fstab mount: /mnt/temp nfs rw,sync,hard,intr 0   0

Produced this: on /mnt/temp type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=,mountvers=3,mountport=49535,mountproto=udp,local_lock=none,addr=

And here is the weird part, now moving the database dir to the /mnt/temp folder, and creating a link to this, it works. I will continue exploring.

Edit3: Solution added as answer, nfs-kernel-server had option --manage-gids in /etc/nfs-kernel-server that affected secondary groups for the mysql user.

  • Why don't you point your MySQL server configuration to that directory instead of using symlinks?
    – Sven
    May 22, 2015 at 9:06
  • Is there anything in your mysqld log?
    – Fox
    May 22, 2015 at 9:13
  • @Sven There are 30 databases, all are stored under different folders on the central storage (/srv/centralstorage/customer1/db/database_dir_1/, /customer2/db/database_dir_2 and so on, which is why every database is symlinked to the folders. The /srv/centralstorage folder has roughly 400 folders, most of them are for apache data, but 30 of them also have databases.
    – FrontSlash
    May 22, 2015 at 9:20
  • @Fox All my mysql logs are quite empty, i will try enabling debuging (i guess?) to see if i can get anything
    – FrontSlash
    May 22, 2015 at 9:20
  • @Fox The general log shows pretty much nothing When the database is local: 150522 11:24:32 967 Connect database1@localhost on 967 Init DB database1 When its symlinked: 150522 11:25:01 968 Connect database1@localhost on 150522 11:25:02 969 Connect database1@localhost on And nothing happens, no errors
    – FrontSlash
    May 22, 2015 at 9:28

2 Answers 2


You don't state what engine are you using, but let me presume it's InnoDB (as it's pretty much standard these days) then in MySQL Docs

(Using actual symbolic links has never been supported for InnoDB tables.)


The DATA DIRECTORY clause is a supported alternative to using symbolic links, which has always been problematic and was never supported for individual InnoDB tables.

You probably could create the .isl files by hand (but test before doing that on live).

And there is one warning that may be of interest:

Do not put MySQL tables on an NFS-mounted volume. NFS uses a message-passing protocol to write to files, which could cause data inconsistency if network messages are lost or received out of order.

Edit: alrighty then... this was not the correct answer, as it's not InnoDB. But I'll keep it in case someone else gets here looking for InnoDB solution.

There is further reading on MySQL and symlinks.

Especially interesting might be

If you are not using symlinks, start mysqld with the --skip-symbolic-links option to ensure that no one can use mysqld to drop or rename a file outside of the data directory.

As that could be default on Debian. (I do not know.)

Edit2: Ok a better way of checking:

SHOW VARIABLES LIKE 'have_symlink';

Another reason for not picking up databases from outside the data-dir is AppArmor, or similar security measure.

btw. it would be worth testing, if it's related to NFS - if symlinks to a completely different part of local fs (or better different fs at all) works it's in NFS, if it doesen't, it's in symlinks ...

  • Its all MyISAM, the server i migrated from is from 2008. Also, the old server has been running the same configuration since it was launched, symlinked databases stored on a central NFS server.
    – FrontSlash
    May 22, 2015 at 9:30
  • symbolic-links TRUE Is the output i get, so it seems to be enabled
    – FrontSlash
    May 22, 2015 at 9:41
  • | have_symlink | YES | Creating a symlink pointing to a local fs works, so i guess it has to be the NFS, damn
    – FrontSlash
    May 22, 2015 at 10:08
  • have you tried reading/writing the symlinked files as user mysql is running under? (not just directories, but the files)
    – Fox
    May 22, 2015 at 10:11
  • I am starting to think that is has something to do with access, what would be a good test to see if mysql has r/w access?
    – FrontSlash
    May 22, 2015 at 12:27

Thanks for the help @Fox and @Sven, i have now solved the problem.

It was a nfs-kernel-server setting, /etc/defaults/nfs-kernel-server contained the option --manage-gids that breaks the usage of secondary groups. So while the mysql user had the right permissions through a secondary group the permissions on the nfs-server's side were wrong.

Hope someone else with the issue sees this before wasting a good few hours!

With regards, FrontSlash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.