Mysql – How to Exempt MySQL from SELinux targeted list

MySQLselinux

I am running CentOS 5.5 and attempting to place MySQL on a non-standard port…which SELinux complains about. MySQL starts perfectly fine on with SELinux off and refuses to start with it on. SELinux is currently running a the type of "targeted"

Not wanting to entirely disable SELinux, I would like to exempt MySQL from the list of targeted daemons. Can anyone tell me how to disable SELinux for this one service?

Best Answer

You don't need to disable SELinux at all. What you need to do is label the port you want use.

To check for the labeled ports for MySQL in the policy:


 # semanage port -l | grep mysql
mysqld_port_t                  tcp      1186, 3306, 63132-63163
mysqlmanagerd_port_t           tcp      2273

To label a $custom port:


 # semanage port -a -t mysqld_port_t -p tcp $custom

The main reference for this is the semanage(8) manpage.