Bug 173618 - Mysql don't initialize if datadir is another place that /var/lib/mysql
Mysql don't initialize if datadir is another place that /var/lib/mysql
Product: Fedora
Classification: Fedora
Component: mysql (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tom Lane
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2005-11-18 13:04 EST by Volnei
Modified: 2013-07-02 23:07 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-11-23 09:22:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Volnei 2005-11-18 13:04:47 EST
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):


How reproducible:

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

Actual results:

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

Expected results:
Normal startup

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
Comment 1 Tom Lane 2005-11-18 13:27:52 EST
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".
Comment 2 Volnei 2005-11-23 05:13:24 EST
Yes, the SELinux was responsable to my 'problem'. 
I correct the policy and the mysql are work now.

Comment 3 Tom Lane 2005-11-23 09:22:38 EST
OK, closing this report as not-a-bug then.  Thanks for letting me know.

Note You need to log in before you can comment on or make changes to this bug.