Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 76051 - mysqld does not start if you move the data directory
Summary: mysqld does not start if you move the data directory
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: mysql
Version: 7.3
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Tom Lane
QA Contact:
: 82152 88117 110657 146867 181614 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2002-10-16 08:57 UTC by Henning Schmiedehausen
Modified: 2013-07-03 02:59 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Last Closed: 2004-12-22 00:13:53 UTC

Attachments (Terms of Use)

Description Henning Schmiedehausen 2002-10-16 08:57:07 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020918

Description of problem:
If you move the mysql data dir in /etc/my.cnf, the server no longer starts.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. add datadir=/mnt/disk1/mysql/data to the mysqld section of /etc/my.cnf
2. move /var/lib/mysql to /mnt/disk1/mysql/data
3. /sbin/service mysqld start

Actual Results:  The server does not start. Warning messages about missing
/var/lib/mysql are emitted

Expected Results:  Server should find the changed data directory and start normally

Additional info:

There is a hardcoded "/var/lib/mysql" in the startup script. Replace 
this with

datadir=`grep -i ^datadir /etc/my.cnf | sed 's/^datadir=//ig'`

Comment 1 Patrick Macdonald 2003-03-04 19:18:12 UTC
It's working as designed.  my.cnf should define exactly were things
are.  It's like moving executable X out of your PATH definition and 
wondering why the OS does find it. Closing as not-a-bug.

Comment 2 Henning Schmiedehausen 2003-03-05 08:23:20 UTC
Did you actually _read_ what I wrote?

I did write "add datadir=/mnt/disk1/mysql/data to the mysqld section of /etc/my.cnf"

So my.cnf _does_ reflect the current configuration on my system. Just the startup
script (which is red hat provided) isn't able to cope with the situation.

I need 'a little more' disk space for my databases than available on the /var
drive and I neither want to do a sub mount nor a symlink (which costs at every
file lookup). All I need is a startup script, that is not brain damaged. I even
sent you a patch.

The problem is not the moved data directory. mysql runs fine with the moved
data directory. It even keeps its socket in /var/lib/mysql. The problem is
the startup script. Did you actually try out what I told you?

(Almost five month of inactivity from RedHat and then "we don't care". Your 
support is really lacking these days.)

Comment 3 Patrick Macdonald 2003-03-05 14:40:19 UTC
Yes, you've changed it in one spot, my.cnf, but not the other.
It was worded a little awkward in my prior reply.  Yes, your script 
resets the datadir in the mysqld init script and yes, I tried using 
it.  If you hardcode the new datadir in the mysqld startup script,
does it work?  Of course it does.  The startup script and my.cnf 
are provided as default scripts / configuation files.  Change as

I'll leave it open as an enhancment request and we'll revisit it
once the current backlog is removed.

As for the time delay, we're sorry about that.  Trond (the previous
owner) no longer works for the company and we're in the process of 
clearing the backlog.

As for the "we don't care"... we do care.  Sometimes a bug is closed
without the resolution that you'd like.  We can't put in everything
suggested and have to make judgement calls.  

Comment 4 Henning Schmiedehausen 2003-03-05 15:44:23 UTC
The /etc/rc.d/init.d/mysqld isn't marked as a configuration file in your RPM
(or it would have the %config identifier). Using a startup script and having
to configure a crucial parameter like the data directory in two different places
(where one is non-obvious), isn't a good solution.

Comment 5 Patrick Macdonald 2003-03-12 16:45:45 UTC
*** Bug 82152 has been marked as a duplicate of this bug. ***

Comment 6 Patrick Macdonald 2003-04-07 13:00:35 UTC
*** Bug 88117 has been marked as a duplicate of this bug. ***

Comment 7 Robert Nedbal 2003-10-20 14:02:27 UTC
Hello to all,
I have recently run into the same problem as described in innitial post. It took
me few HOURS until I have discovered that init.d/mysqld is broken. Then I have
found this almost 1 year old bugzilla record. Please, why is it such a big
problem to correct datadir in /etc/init.d/mysqld and as a result to fix this
annoying bug? Simply replace

datadir=`grep -i ^datadir /etc/my.cnf | sed 's/^datadir=//ig'`

I suppose /etc/my.cnf is considered as a regular CONFIGURATION file which can be
freely changed at any time. But when I do this, MySQL init scripts stop working.
This I really consider as a bug, not an _enhancement_.

Can I hope that this will be fixed in next MySQL RPM-package update?

Thanks && best regards,
Robert Nedbal

Comment 8 Patrick Macdonald 2003-11-24 15:25:46 UTC
*** Bug 110657 has been marked as a duplicate of this bug. ***

Comment 9 Tom Lane 2004-03-12 01:02:52 UTC
It looks to me like most of the entries in /etc/my.cnf are effectively
hard-coded in the init script: I see references to the socket, the
err-log, and the pid-file as well as the datadir.  If we're gonna do
anything about this we'd really need to fix them all.  The proposed
"grep" solution is simple but I think it is too fragile.  What happens
if there are multiple lines in different sections that match the grep
pattern --- which one is right, and how would we get the script to
pick it?  Also, does the MySQL code allow comments on the same line as
a variable setting, and if so what do they look like?

Comment 10 Tom Lane 2004-12-22 00:13:53 UTC
I've finally taken the time to fix the init script as of mysql
4.1.7-8.  It will now honor settings in /etc/my.cnf for the
aforementioned values.

Comment 11 Tom Lane 2005-02-02 15:25:19 UTC
*** Bug 146867 has been marked as a duplicate of this bug. ***

Comment 12 Ruth Ivimey-Cook 2005-02-02 20:58:10 UTC
Just discovered this bug, and despite Tom Lane'd comment the issue
still exists in latest FC3. Along with the others, I regard the issue
as a bug in the init script.

Comment 13 Tom Lane 2006-02-15 15:28:09 UTC
*** Bug 181614 has been marked as a duplicate of this bug. ***

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