Symlinking MySQL data files
January 19th, 2012 at 18:01:30 (technology)
Due to space issues, I had to move my MySQL data files (/var/lib/mysql) on a Ubuntu box to another file system. I did that and created a symlink, but MySQL would not start. It turns out to be an easy fix. I found a post on MySQL Forums from someone who had a similar problem, and someone named Richard Guy posted my solution:
Did you fix the apparmor config file for mysqld and restart apparmor?
first you need to edit /etc/apparmor.d/usr.sbin.mysqld and add the new fully qualified (ie, no symbolic link) path(s). [you may want to leave the original /var/lib/mysql entries intact ]
then “restart” apparmor:
sudo invoke-rc.d apparmor reload
for more info, see https://help.ubuntu.com/community/AppArmor
I edited the file as appropriate, and MySQL started fine and now I don’t have to worry about my disk space filling up again.