How to change MySQL data directory?
Posted
by
Jonathan Frank
on Server Fault
See other posts from Server Fault
or by Jonathan Frank
Published on 2011-06-29T21:04:40Z
Indexed on
2012/10/31
5:07 UTC
Read the original article
Hit count: 521
I want to place my databases in another directory, so I can store them in an ESB (elastic block storage, just a fancy name for a virtualized harddisk) together with my web-apps and other persistent data.
I have tried to walk through a tutorial at http://crashmag.net/change-the-default-mysql-data-directory-with-selinux-enabled.
Everything seems fine until I type this command:
# semanage fcontext -a -t mysqld_db_t "/srv/mysql(/.*)?"
Then the command fails and tells me that mysqld_db_t is an invalid SELinux context even if the default MySQL data directory is labelled with this context. I am running Fedora 15 on Virtualbox (behaves like an ordinary x86-compatible box) and Amazon EC2 (based on Xen) so the tutorial should be compatible.
It is also worth to mention that turning off SELinux globally or just for the MySQL process is not an option, because such a solution will decrease the security of the system if a hacker gains access to the system via the MySQL server. I have never seen this problem before I changed to the Redhat/Fedora architecture, so it could be a distribution specific issue.
Any help is highly appreciated
© Server Fault or respective owner