Change the data directory in Redhat Linux Enterprise with sellinux on
Today I had to change the data directory for a MySQL database in Redhat 5 Enterprise Edition with selinux set to enforcing mode. This was in a NEW INSTALL so there was no existing data. I stress this because this method is not a method one uses to RELOCATE existing data.
Here are the steps:
Here are the steps:
- Stop the database => service mysqld stop
- Edit /etc/my.cnf and change the datadir value to the desired location.
- Change the selinux user / role and type on the new location.
- chcon -u system_u -r (cantremember_r) -t mysqld_db_t /full/path/to/mysql/data/dir
- Change the owner:group on the datadir
- chown mysql:mysql /full/path/to/mysql/data/dir
- Change the file permissions on the datadir
- chmod 755 /full/path/to/mysql/data/dir
- Start the database => service mysqld start
- Hold thumbs... :)
UPDATE *** 2011-07-21 ***