Red Hat Bugzilla – Bug 173618
Mysql don't initialize if datadir is another place that /var/lib/mysql
Last modified: 2013-07-02 23:07:34 EDT
Description of problem:
If I change datadir parameter in /etc/my.cnf file to another place that
/var/lib/mysql, the mysql don't initialize.
The problem is in init.d/mysqld script I try initialize mysql via older
scripts and it was started with success.
Then I'm using mysqld script from tarball from MySQLAB packet.
Version-Release number of selected component (if applicable):
1. Create a directory, eg. /mysql and make a chown mysql:mysql /mysql
2. Move /var/lib/mysql to /var/lib/mysql.old
3. Create a symlink. eg ln -sf /mysql /var/lib/mysql
4. After change the references into /etc/my.cnf to /mysql.
5. Try start the mysql
example: datadir=/var/lib/mysql change to /mysql
051118 14:21:54 mysqld started
051118 14:21:54 [Warning] Can't create test file /var/lib/mysql/lab.lower-test
^G/usr/libexec/mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
051118 14:21:54 [ERROR] Aborting
051118 15:38:59 mysqld started
051118 15:39:00 InnoDB: Started; log sequence number 0 43634
/usr/libexec/mysqld: ready for connections.
Version: '4.1.14' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source
Are you running with SELinux enforcement enabled (see /usr/sbin/getenforce)?
If so, I believe the default security policy constrains the mysql daemon to
write only under /var/lib/mysql. To move the database somewhere else, you'd
need to adjust the security policy.
You could check whether this is the problem by seeing if mysql will start after
doing "sudo /usr/sbin/setenforce 0".
Yes, the SELinux was responsable to my 'problem'.
I correct the policy and the mysql are work now.
OK, closing this report as not-a-bug then. Thanks for letting me know.