SELinux is furious about different mysql db location

Dave Quigley selinux at davequigley.com
Fri Jun 10 09:51:32 UTC 2011


On 6/10/2011 5:12 AM, Hiisi wrote:
> Hi, list!
> I would like to change default location for MySQL databases. So I
> copied /var/lib/mysql to /srv/lib/ and changed datadir variable in
> /etc/my.cnf from default /var/lib/mysql to /srv/lib/mysql. Since that
> I'm unable to start mysqld service. With every effort I got AVC denial
> messages suggesting me to do the following:
> # semanage fcontext -a -t FILE_TYPE 'mysql'
> where FILE_TYPE is one of the following: mysqld_var_run_t,
> mysqld_db_t, tmp_t, mysqld_tmp_t, user_home_t, var_lib_t, var_run_t,
> var_log_t, root_t.
> Then execute:
> restorecon -v 'mysql'
> I tried all types of FILE_TYPE without success. I even tried to execute:
> grep mysqld /var/log/audit/audit.log | audit2allow -M mypol
> # semodule -i mypol.pp
> With no luck either. What should I do to make this configuration
> works? Please do not suggest me to shut down selinux. This machine
> runs ssh+ftp+httpd services and has static IP.
> TIA

Instead of doing the individual semanage commands on each file try this 
instead.

semanage fcontext -ae /var/lib/mysql /srv/lib/mysql
restorecon -Rv /srv/lib/mysql

That should tell selinux that /var/lib/mysql and /srv/lib/mysql are to 
be treated the same and the restorecon should fix up the labels.

Dave


More information about the users mailing list