Bug #34542 mysql_install_db fails if /etc/mysql/my.cnf exists with different basedir
Submitted: 14 Feb 2008 11:41 Modified: 4 Mar 2008 15:14
Reporter: Susanne Ebrecht Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:5.1, 6.0 OS:Linux
Assigned to: Mattias Jonsson CPU Architecture:Any
Triage: D2 (Serious)

[14 Feb 2008 11:41] Susanne Ebrecht
Description:
I got a new PC and installed Ubuntu 64bit.

I didn't want to install MySQL.

But by accident, one of the packages, that I installed, installed some fragments of MySQL.

After my OS and some additional software was installed, I cloned all MySQL versions with bk.

No problems with 5.0. All worked immediately.

But I couldn't install 6.0 and 5.1.

miracee@ernie:~/mysql60bk$ ./bin/mysql_install_db 

FATAL ERROR: Could not find /fill_help_tables.sql

...

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

miracee@ernie:~/mysql60bk$ ./bin/mysql_install_db --basedir=/home/miracee/mysql60bk

same error

at least I figured out, that there is:

/etc/mysql/my.cnf

I wondered, and just made a:
# rm -rf /etc/mysql

After this, the installation of 5.1 and 6.0 works fine.

How to repeat:
Get root.

Add a mysql/my.cnf to /etc

my.cnf should contain:
basedir=/something

Get user and switch to your mysql directory at your home.

$ ./bin/mysql_install_db

Suggested fix:
This don't happens with 5.0, so there should be a difference between 5.0 and 5.1/6.0.

Just let mysql_install_db work like at 5.0
[28 Feb 2008 11:36] Mattias Jonsson
Not a bug.

The /etc/mysql/my.cnf file was added as a global options file in 5.1.15.
(noted in the manual http://dev.mysql.com/doc/refman/5.1/en/option-files.html)

It is the same behavior as if one have the same content (using the basedir-option) in a /etc/my.cnf file in 5.0.

Workaround is to use a proper --basedir=<...> or --no-defaults when calling the mysql_install_db script if one do not want to correct the /etc/my.cnf or /etc/mysql/my.cnf file.
[4 Mar 2008 11:18] Susanne Ebrecht
Mattias,

as I wrote:

" ./bin/mysql_install_db --basedir=/home/miracee/mysql60bk

same error"

This means, the --basedir=<...> has no effect and that is a bug.
[4 Mar 2008 13:31] Mattias Jonsson
Strange, since it works as I described on both 5.0.56 and 6.0.4 tar.gz packages in Mac OS X 10.5:
sh-3.2# head /etc/my.cnf /etc/mysql/my.cnf 
==> /etc/my.cnf <==
[mysqld]
basedir = /usr/local/mysql-data-etc.old

==> /etc/mysql/my.cnf <==
[mysqld]
basedir = /usr/local/mysql-data-etc-mysql.old

sh-3.2# ./scripts/mysql_install_db 

FATAL ERROR: Could not find /fill_help_tables.sql

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

sh-3.2# ./scripts/mysql_install_db --basedir=/usr/local/mysql-6.0.4-alpha-osx10.5-x86
Installing MySQL system tables...
OK
Filling help tables...
OK
....

sh-3.2# cd ../mysql-enterprise-gpl-5.0.56-osx10.5-x86/
sh-3.2# ./scripts/mysql_install_db FATAL ERROR: Could not find fill_help_tables.sql inside --basedir

When using --basedir you must point either into a MySQL binary
distribution directory or a compiled tree previously populated
by 'make install'
sh-3.2# ./scripts/mysql_install_db --basedir=/usr/local/mysql-enterprise-gpl-5.0.56-osx10.5-x86
Installing MySQL system tables...
080304 12:39:04 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-enterprise-gpl-5.0.56-osx10.5-x86/data/ is case insensitive
OK
Filling help tables...
080304 12:39:05 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-enterprise-gpl-5.0.56-osx10.5-x86/data/ is case insensitive
OK

....

Will try to verify it on Linux.

What distribution do you use? (I cannot find mysql_install_db in bin/ it should be in scripts/)
[4 Mar 2008 14:18] Susanne Ebrecht
This is fixed in newest source tree.
[4 Mar 2008 14:32] Susanne Ebrecht
I was to fast. It fails with newest bk tree too.

When there is a global /etc/mysql/my.cnf where datadir are defined, mysql_install_db ignores the --basedir and choose the global my.cnf instead of using the my.cnf that is defined at the base dir or using no configuration.
[4 Mar 2008 15:14] Mattias Jonsson
After discussion with Susanne we come to the conclusion that this bug can be closed.

if there is one or more options files (see http://dev.mysql.com/doc/refman/5.1/en/option-files.html) then they will be used unless --no-defaults are given. To override the options from the options files one can give --basedir and --datadir to make mysql_install_db work for a non-privileged user. (please see the manual how to use command-line options and options file).

The confusion was that from 5.1.15 the file /etc/mysql/my.cnf was added as a global options file (and is not used in 5.0).
[19 Feb 2009 5:34] Trent Lloyd
Is it possible to change the preference to prefer /etc/my.cnf over /etc/mysql/my.cnf ?

This will cause problems for lots of Ubuntu users installing MySQL as my.cnf is installed by 'mysql-common' which is installed for any mysql lclient using application.

Have had 2 customer issues with this so far.
[19 Feb 2009 9:40] Susanne Ebrecht
Trent,

$ ./libexec/mysqld --verbose --help | less

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /home/miracee/mysql51bzr/etc/my.cnf ~/.my.cnf

Is that ok for you?

Seems to be fixed in actual 5.1 bzr tree.
[19 Feb 2009 10:28] Susanne Ebrecht
Trent,

sorry, I made a mistake here. Order from help output seems not to be correct.

Please open an own bug report for it and start a discussion.