Relocate MySQL DB dir to "/home/mysql"... Okay to do that?


For purposes of some protection against HDD failure, I intend to put “/home” on a RAID-1. In addition to the server owner homes, I’d like to have the MySQL database directory there.

So (after stopping the server) I moved the contents of /var/lib/mysql to /home/mysql, gave that directory the proper owner and permissions, added access to it to /etc/apparmor.d and changed the path in MySQL’s config file.

Server seems to run fine with that change. Would there be any further caveats here concerning Virtualmin? Or does it not care where MySQL’s data directory is? :slight_smile: (I suppose for backup purposes, it will use SQL dumps anyway, and not copy away the data directory contents.)


I suspect that, for the most part, Virtualmin doesn’t care too much about where you put that.

Virtualmin does attempt to set the group permission on the database file to match the Virtual Server owner… but it should be able to find that based on the data directory setting in your MySQL config. You can verify that Virtualmin sees the correct data dir by taking a peek at Webmin -> Servers -> MySQL Database Server -> MySQL Server Configuration, and look at “Databases files directory”.


Thanks for your reply Eric!

Creating the DB during domain creation seems to be working fine. I already had found that setting in the Webmin MySQL module, which was explicitly set to /var/log/mysql, and changed it accordingly.