Bug 173618 - Mysql don't initialize if datadir is another place that /var/lib/mysql
Summary: Mysql don't initialize if datadir is another place that /var/lib/mysql
Alias: None
Product: Fedora
Classification: Fedora
Component: mysql   
(Show other bugs)
Version: 4
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Tom Lane
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2005-11-18 18:04 UTC by Volnei
Modified: 2013-07-03 03:07 UTC (History)
1 user (show)

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

Attachments (Terms of Use)

Description Volnei 2005-11-18 18:04:47 UTC
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 18:27:52 UTC
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 10:13:24 UTC
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 14:22:38 UTC
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.