LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   SELinux Blocking MySQL Data Dir Moved - Standard Solution not working (https://www.linuxquestions.org/questions/linux-security-4/selinux-blocking-mysql-data-dir-moved-standard-solution-not-working-4175561249/)

BigMike44 12-11-2015 12:29 PM

SELinux Blocking MySQL Data Dir Moved - Standard Solution not working
 
I am reinstalling linux Centos 6 to have the OS on an SSD. In the process Ihave moved my MySQL data directory onto a HDD, made the necessary modifications to my.cnf and now SELinux is preventing mySQL from starting.

I have discovered a workaround for this so I'm asking this forum for a proper fix.

The typical fix for this, to set a new SELinux context for the new data directory location isn't working. I believe it has something to do with the full path of the data directory not satisfying SELinux because I can get it to work using the command below:

As instructed:
semanage fcontext -a -t mysqld_db_t "/mnt/HDD0/DBData/mysql(/.*)?" -> MySQL can't start
Temporary work around:
semanage fcontext -a -t mysqld_db_t "/mnt(/.*)?" -> MySQL can start.

It is a requirement for me to put the data directory in /mnt/HDD0/DBData/.

I'd like to do this properly. I am currently reading the Red Hat SELinux manual, and I am finding it daunting.

Notes:
I am using Centos 6.4, MySQL 5.6, and.

I have followed the instructions on both of the following.
https://blogs.oracle.com/jsmyth/entry/selinux_and_mysql
https://access.redhat.com/documentat..._Examples.html

Habitual 12-11-2015 12:56 PM

Quote:

Originally Posted by BigMike44 (Post 5462939)
As instructed:
semanage fcontext -a -t mysqld_db_t "/mnt/HDD0/DBData/mysql(/.*)?" -> MySQL can't start
Temporary work around:
semanage fcontext -a -t mysqld_db_t "/mnt(/.*)?" -> MySQL can start.

How about
Code:

semanage fcontext -a -t mysqld_db_t "/mnt/HDD0/DBData(/.*)?"
?

BigMike44 12-11-2015 01:54 PM

Working on it. Right now trying to figure out how to remove the context I added for /mnt.

BigMike44 12-11-2015 02:19 PM

I can't test out your suggestion because I've lost the configuration of the system that produces the problem.

I issued the following command to delete the context:

semanage fcontext -d "/mnt(/.*)?"

and after rebooting now MySQL starts without any problem!

I'll check again today for any feedback, but at this point, I'm not willing to install the OS again to solve this problem.


All times are GMT -5. The time now is 08:24 AM.