Moving mysql datadir to other location
Moving mysql datadir to other location
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
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
Moving mysql datadir to other location
How about sharing with us the commands you ran to change the context and an `ls -laZ` of the current settings.
Re: Moving mysql datadir to other location
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
Sorry for the noise and thanks again,
Ilko
Re: Moving mysql datadir to other location
You are right ! SElinux will not allow to change default mysql database directory.
Have u tried something like :
[code] chcon -R system_u:object_r:mysqld_db_t /NEWDATABASEDIR/[/code] .
Maybe u have to modify this command to your needs .
Try [code] man chcon [/code] 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
Have u tried something like :
[code] chcon -R system_u:object_r:mysqld_db_t /NEWDATABASEDIR/[/code] .
Maybe u have to modify this command to your needs .
Try [code] man chcon [/code] 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
Re: Moving mysql datadir to other location
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.
Re: Moving mysql datadir to other location
Does anybody know what default / core package has to be install for semanage ?
Cheers
Sisko
Cheers
Sisko
Re: Moving mysql datadir to other location
[code]
# rpm -qf `which semanage`
policycoreutils-1.33.12-14.8.el5.x86_64
[/code]
# rpm -qf `which semanage`
policycoreutils-1.33.12-14.8.el5.x86_64
[/code]
Re: Moving mysql datadir to other location
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 ....
Very strange ....
Re: Moving mysql datadir to other location
Sorry, that was from my main CentOS 5 machine
[code]
# rpm -qf `which semanage`
policycoreutils-python-2.0.83-19.8.el6_0.i686
[/code]
[code]
# rpm -qf `which semanage`
policycoreutils-python-2.0.83-19.8.el6_0.i686
[/code]
Re: Moving mysql datadir to other location
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]
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 ! [/code]
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
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]
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 ! [/code]
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