1

I'm using mysql 5.5 on an ubuntu linux server. I need to move a database from its current location (under /var/lib/mysql) to a disk with more space, so I attempted to move the directory and create a symlink to the new location. When I do this, I get

ERROR 1018 (HY000): Can't read dir of './<dbname>/' (errno: 13)

when I attempt to show tables after starting mysql again. The error goes away if I move the database directory back to its original location. (But, I need to move to a larger disk, so I've got to figure this out somehow)

I've looked around on this site and google; The documentation and the accepted answer to this question indicates what I'm doing should work (I'm attempting to use option 3 from the accepted answer).

So, is this still supported? If so, what am I doing wrong?

Here's some additional information to jumpstart things:

  • when I run ls -lL /var/lib/mysql all the files are owned by mysql (user & group)
  • I've also changed ownership of the actual symlink to mysql:mysql (due to comments on this question)
  • Both filesystems are on local disks (ext4)
Gus
  • 133
  • 6

1 Answers1

2

It turns out that the ubuntu mysql package uses apparmor. I found a github blog entry (no longer available a/o Oct 2019) describing my scenario and the steps to fix it, summarized below:

Here's the gotcha: Ubuntu comes with AppArmor. AppArmor's security model is to bind access control attributes to programs rather than to users. In my /etc/apparmor.d/usr.sbin.mysqld file I've made these changes:

 # I disabled these two lines;
 # Comments indicate you don't need to
 /var/lib/mysql/ r,
 /var/lib/mysql/** rwk,
 # Added these two lines
 /example_ssd_partition/mysql/data r,
 /example_ssd_partition/mysql/data/** rwk,
Gus
  • 133
  • 6