Moving mysql datadir to other location

Issues related to applications and software problems

Moving mysql datadir to other location

Postby okli » 2011/08/29 08:13:22

Hi,

I've spent very long time trying to move my mysql datadir from ist current location /var/lib/mysql to my /data partition without any luck. The problem as stated already in google is that SELinux denies the access to the new created datadir. I've followed some very good instructions provided to set the fscontext so that the filesystem will be accessible to mysql, but the access is still denied. Someone got this to work on CentOS 6 64bit with the provided mysql-5.1 version, as installed by yum install mysql-server mysql? I'm cosidering this is almost "stadard installation", so can someone here describe the necessary security options please. Any help will be highly appreciated.

TIA,
Ilko
okli
 
Posts: 2
Joined: 2011/08/29 07:57:46

Moving mysql datadir to other location

Postby TrevorH » 2011/08/29 12:11:08

How about sharing with us the commands you ran to change the context and an `ls -laZ` of the current settings.
User avatar
TrevorH
Forum Moderator
 
Posts: 13678
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Moving mysql datadir to other location

Postby okli » 2011/08/30 07:38:51

Hi, thanks for the reply and sorry for my delay. Unfortunately, I've re-installed the machine completely and replaced mysql with postgresql. Now I can define my data storage on /data/postgres and this "solves" my problem. OTOH, it will be interesting if someone can share the knowledge how this problem can be really solved on CentOS 6. As far as I can see others had success with this issue on 5.5, but I couldn't find anything regarding v6 so far.

Sorry for the noise and thanks again,
Ilko
okli
 
Posts: 2
Joined: 2011/08/29 07:57:46

Re: Moving mysql datadir to other location

Postby sisko255 » 2011/09/06 09:23:44

You are right ! SElinux will not allow to change default mysql database directory.


Have u tried something like :


Code: Select all
 chcon -R system_u:object_r:mysqld_db_t /NEWDATABASEDIR/
.

Maybe u have to modify this command to your needs .


Try
Code: Select all
 man chcon
for more information !


Also check your user and file permissions or copy databases with cp -rp option to preserve user and file permissions

Cheers

Sisko
sisko255
 
Posts: 6
Joined: 2011/09/06 09:14:54

Re: Moving mysql datadir to other location

Postby TrevorH » 2011/09/06 11:30:17

Using chcon can be a bit dangerous because the changed context may be reset if the entire filesystem is relabeled at some point in the future. Better to look at using `semanage fcontext ...` as that puts persistent rules in place that a relabel uses.
User avatar
TrevorH
Forum Moderator
 
Posts: 13678
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Moving mysql datadir to other location

Postby sisko255 » 2011/09/08 08:31:04

Does anybody know what default / core package has to be install for semanage ?

Cheers

Sisko
sisko255
 
Posts: 6
Joined: 2011/09/06 09:14:54

Re: Moving mysql datadir to other location

Postby TrevorH » 2011/09/08 09:35:30

Code: Select all
# rpm -qf `which semanage`
policycoreutils-1.33.12-14.8.el5.x86_64
User avatar
TrevorH
Forum Moderator
 
Posts: 13678
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Moving mysql datadir to other location

Postby sisko255 » 2011/09/08 12:20:29

Interesting ..... it seems the policycoreutils.x86_64 (policycoreutils-2.0.83-19.8.el6_0.x86_64) does not include the semanage bin in my case.


Very strange ....
sisko255
 
Posts: 6
Joined: 2011/09/06 09:14:54

Re: Moving mysql datadir to other location

Postby TrevorH » 2011/09/08 12:41:30

Sorry, that was from my main CentOS 5 machine

Code: Select all
# rpm -qf `which semanage`
policycoreutils-python-2.0.83-19.8.el6_0.i686
User avatar
TrevorH
Forum Moderator
 
Posts: 13678
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Moving mysql datadir to other location

Postby sisko255 » 2011/09/08 13:00:42

Thanks,

but this does not change my problem . It seems there is no binary called " semanage " in my policycoreutils-2.0.83-19.8.el6_0.x86_64 package. I installed the policycoreutils via yum . But still no semanage . That is very strange.


Code: Select all
yum install policycoreutilsPackage policycoreutils-2.0.83-19.8.el6_0.x86_64

.... already installed and latest version


rpm -qf `which semanage`


/usr/bin/which: no semanage in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/open-xchange/sbin/:/root/bin)

find / |grep semanager

nothing found ! 


I also did a yum remove of the package and yum install it again. To check if i deleted semanage without intention. - Still same problem .

Any Ideas ?

Cheers

Sisko
sisko255
 
Posts: 6
Joined: 2011/09/06 09:14:54

Next

Return to CentOS 6 - Software Support

Who is online

Users browsing this forum: No registered users and 3 guests