MySQL custom datadir location - other daemons too

Jan-Frode Myklebust mykleb at no.ibm.com
Fri Apr 20 19:12:24 UTC 2007


These are the selinux labeling rules for mysql:

# grep mysql /etc/selinux/targeted/contexts/files/file_contexts
/etc/mysql(/.*)?        system_u:object_r:mysqld_etc_t:s0
/var/log/mysql.*        --      system_u:object_r:mysqld_log_t:s0
/var/lib/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0
/var/run/mysqld(/.*)?   system_u:object_r:mysqld_var_run_t:s0
/usr/sbin/mysqld(-max)? --      system_u:object_r:mysqld_exec_t:s0
/etc/my\.cnf    --      system_u:object_r:mysqld_etc_t:s0
/usr/libexec/mysqld     --      system_u:object_r:mysqld_exec_t:s0
/var/lib/mysql/mysql\.sock      -s      system_u:object_r:mysqld_var_run_t:s0

It seems you're moving /var/lib/mysql to /db/mysql, and the following 
new labeling rule should set the right labels for the db:

	# Add new labeling rule:
	/usr/sbin/semanage fcontext -a -t mysqld_db_t "/db/mysql(/.*)?"
	# Restore labels based on labeling rules:
	restorecon -R /db/mysql

But, I'm quite uncertain on how to map your tmpdir and basedir. What
where the original location of these ? Once you find these, it will
likely be easy to create similar new labeling rules for these, and
your new database location should be OK.

On the other hand.. I would have just mounted the storage array as
/var/lib/mysql, run "restorecon -R /var/lib/mysql" and not have
needed to change much in either selinux or mysql startup for getting
it working.


  -jf




More information about the fedora-selinux-list mailing list