LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Mysqld won't start with Selinux enforcing turned on (https://www.linuxquestions.org/questions/linux-general-1/mysqld-wont-start-with-selinux-enforcing-turned-on-734067/)

jdnow09 06-18-2009 11:17 PM

Mysqld won't start with Selinux enforcing turned on
 
Guys,


I changed the default data location for mysql. Modified my.cnf on /etc.

Give mysql access to the new directory and moved the databases over.


Everything works fine. But when I turn selinux to 'enforcing', mysqld won't start.

How do I workaround this and be able to still have selinux be in 'enforcing' mode


Thanks in advance.

John

billymayday 06-19-2009 12:05 AM

The context for the directory has to be correct, so for example
Quote:

]# ls -dZ /var/lib/mysql
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t /var/lib/mysql
so "chcon system_u:object_r:mysqld_db_t /path/to/directory" should help

jdnow09 06-19-2009 02:13 PM

Billymayday,

I finally got around to try it but I don't have any luck. Getting "Timeout error occurred trying to start MySQL Daemon."


selinux is off

[root@centos53a ~]# ls -dZ /var/lib/mysql
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t:s0 /var/lib/mysql


[root@centos53a ~]# ls -dZ /u03
drwxr-xr-x mysql mysql /u03


*** I did the command you suggested below, /u03 is the new location of mysql in my.cnf file ***

[root@centos53a ~]# chcon system_u:object_r:mysqld_db_t:s0 /u03


[root@centos53a ~]# ls -dZ /u03
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t:s0 /u03

selinux is on

reboot

*** after reboot, it shows the following***

[root@centos53a /]# ls -dZ /var/lib/mysql
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t /var/lib/mysql



[root@centos53a /]# ls -dZ /u03
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t /u03


-John

jdnow09 06-24-2009 01:37 PM

Quote:

Originally Posted by jdnow09 (Post 3579944)
Billymayday,

I finally got around to try it but I don't have any luck. Getting "Timeout error occurred trying to start MySQL Daemon."


selinux is off

[root@centos53a ~]# ls -dZ /var/lib/mysql
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t:s0 /var/lib/mysql


[root@centos53a ~]# ls -dZ /u03
drwxr-xr-x mysql mysql /u03


*** I did the command you suggested below, /u03 is the new location of mysql in my.cnf file ***

[root@centos53a ~]# chcon system_u:object_r:mysqld_db_t:s0 /u03


[root@centos53a ~]# ls -dZ /u03
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t:s0 /u03

selinux is on

reboot

*** after reboot, it shows the following***

[root@centos53a /]# ls -dZ /var/lib/mysql
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t /var/lib/mysql



[root@centos53a /]# ls -dZ /u03
drwxr-xr-x mysql mysql system_u:object_r:mysqld_db_t /u03


-John


Finally got it to work with the following:



chcon -Rv --type=system_u:object_r:mysqld_db_t my_new_dir

I just needed to give both the files and directory access.

Thanks again.


John


All times are GMT -5. The time now is 12:06 AM.