Bug #63632 Cannot access database via symbolic link to a different filesystem
Submitted: 6 Dec 2011 17:40 Modified: 7 Sep 2012 19:14
Reporter: Terry Tuck Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5.18-1, 5.5.20 OS:Linux (RHEL 5)
Assigned to: CPU Architecture:Any

[6 Dec 2011 17:40] Terry Tuck
Description:
Cannot use symbolic link created within mysql data dir to represent a database stored on a filesystem other than the system disk.  (symbolic links work correctly when target is on system disk.)

How to repeat:
Following instructions listed in section 7.11.3.1.1 of refman-5.5:
1. Mount a different filesystem
2. in data dir, as user running mysqld, create symbolic link to different filesystem.
3. as user running mysqld, navigate symbolic link to test access privs at target
4. in mysql, use 'show databases' to see that symbolic link is not recognized as db-path/database.

Details of steps:
[root@localhost /]# mysqld --verbose --help | grep symbolic
111206 11:21:56 [Note] Plugin 'FEDERATED' is disabled.
  -s, --symbolic-links
                      Enable symbolic link support.
                      (Defaults to on; use --skip-symbolic-links to disable.)
symbolic-links                                    TRUE
[root@localhost /]# cd /var/lib/mysql
[root@localhost mysql]# mkdir /system_disk
[root@localhost mysql]# chown mysql:mysql /system_disk
[root@localhost mysql]# su mysql
bash-3.2$ ln -s /system_disk .
bash-3.2$ cd system_disk
bash-3.2$ touch test-file
bash-3.2$ ls -l
total 4
-rw-r--r-- 1 mysql mysql 0 Dec  6 11:24 test-file
bash-3.2$ rm test-file
bash-3.2$ exit
exit
[root@localhost mysql]# mount /dev/sdc1 /dev/different_disk
[root@localhost mysql]# su mysql
bash-3.2$ ln -s /dev/different_disk .
bash-3.2$ cd different_disk
bash-3.2$ touch test-file
bash-3.2$ ls -l
total 20
drwx------ 2 root  root  16384 Dec  5 20:19 lost+found
-rw-r--r-- 1 mysql mysql     0 Dec  6 11:25 test-file
bash-3.2$ rm test-file
bash-3.2$ exit
exit
[root@localhost mysql]# ls -l
total 28776
lrwxrwxrwx 1 mysql mysql       19 Dec  6 11:25 different_disk -> /dev/different_disk
-rw-rw---- 1 mysql mysql 18874368 Dec  6 11:01 ibdata1
-rw-rw---- 1 mysql mysql  5242880 Dec  6 11:01 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 Dec  6 07:38 ib_logfile1
drwx--x--x 2 mysql mysql     4096 Dec  6 07:29 mysql
srwxrwxrwx 1 mysql mysql        0 Dec  6 11:01 mysql.sock
drwx------ 2 mysql mysql     4096 Dec  6 07:29 performance_schema
-rw-r--r-- 1 mysql mysql      113 Dec  6 07:29 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql      113 Dec  6 07:29 RPM_UPGRADE_MARKER-LAST
lrwxrwxrwx 1 mysql mysql       12 Dec  6 11:24 system_disk -> /system_disk
[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| system_disk        |
+--------------------+
4 rows in set (0.00 sec)

mysql>
[20 Dec 2011 16:26] Sveta Smirnova
Thank you for the report.

Please check: if you restart MySQL server after mounting different disk will it recognize the link?

Please also indicate which filesystem this disk uses: I tested with ext4 and NTFS and everything worked fine.
[21 Dec 2011 18:27] Terry Tuck
Thank you for working on this.

No - rebooting server (which include mysqld restart) has no affect, and type of file system doesn't matter.

Details from after reboot, and without performing manual mounts:
[root@localhost ~]# cd /var/lib/mysql
[root@localhost mysql]# cat /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb1               /mantis-filesystem      ext4    defaults        0 2
/dev/sdc1               /mantis                 ext3    defaults        0 2
[root@localhost mysql]# ls -ld *
lrwxrwxrwx 1 mysql mysql       12 Dec 21 11:47 ext3 -> /mantis/ext3
lrwxrwxrwx 1 mysql mysql       34 Dec 21 11:47 ext4 -> /mantis-filesystem/mysql_data/ext4
-rw-rw---- 1 mysql mysql 18874368 Dec 21 12:05 ibdata1
-rw-rw---- 1 mysql mysql  5242880 Dec 21 12:09 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 Dec  6 07:38 ib_logfile1
drwx--x--x 2 mysql mysql     4096 Dec  6 07:29 mysql
srwxrwxrwx 1 mysql mysql        0 Dec 21 12:09 mysql.sock
drwx------ 2 mysql mysql     4096 Dec  6 07:29 performance_schema
-rw-r--r-- 1 mysql mysql      113 Dec  6 07:29 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql      113 Dec  6 07:29 RPM_UPGRADE_MARKER-LAST
-rw-rw---- 1 mysql mysql        5 Dec 21 12:09 localhost.pid
[root@localhost mysql]# su mysql
bash-3.2$ cd ext3
bash-3.2$ ls -l
total 8
drwxr-xr-x 2 mysql mysql 4096 Dec 21 12:04 testdirectory1
bash-3.2$ cd ../ext4
bash-3.2$ ls -l
total 4
drwxr-xr-x 2 mysql mysql 4096 Dec 21 12:05 testdirectory2
bash-3.2$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
[22 Dec 2011 17:29] Sveta Smirnova
Thank you for the feedback.

Which package do you use (filename you downloaded)? Could you please try with latest binary available from dev.mysql.com/downloads?
[23 Jan 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[25 Jan 2012 17:18] Michael Shestero
I have the similar problem width two ext3 systems.
mysqld  Ver 5.1.41-3ubuntu12.10 for debian-linux-gnu on x86_64 ((Ubuntu))

see also: http://rsdn.ru/forum/db/4590487.flat.aspx
[26 Jan 2012 17:11] Terry Tuck
The file used was MySQL-server-5.5.18-1.rhel5.x86_64.rpm
[30 Jan 2012 20:11] Sveta Smirnova
Thank you for the feedback.

Do yo have SELinux enabled?
[30 Jan 2012 23:52] Sveta Smirnova
I can not repeat described behavior with indicated package as well. Please also check user rights for mounted device: check mount output after you mounted it and mount options you used.
[2 Feb 2012 22:53] Terry Tuck
Sveta: thank you for continuing on this.

No SELinux

No quotas in use on system

filesystems mounted via fstab, using arguments:
/dev/sdb1  ext3   defaults  0 2
/dev/sdc1  ext4   defaults  0 2

Problem also exists when using MySQL-server-5.5.20-1.rhel5.x86_64.rpm and MySQL-server-5.5.20-1.rhel5.i386.rpm

I'm using mysql_secure_installation after install.
[7 Sep 2012 18:56] Sveta Smirnova
Thank you for the feedback.

Please send us your configuration file also.
[7 Sep 2012 19:02] Terry Tuck
This was indeed a SELinux issue.  After SELinux was disabled all problems were resolved.

To check if SELinux is running:  ls /selinux
if the directory is empty, then not running.  If NOT empty, then set SELinux to disable enforcement.

Sveta: my apologies for time you spent on this.
[7 Sep 2012 19:14] Sveta Smirnova
Thank you for the feedback.

Closed as not a bug.