Bug #30759 mysql_install_db fails to set $extra_bindir properly in all cases.
Submitted: 1 Sep 2007 22:33 Modified: 3 Dec 2007 9:52
Reporter: Matthew Montgomery Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:5.1.21 OS:Any
Assigned to: Jonathan Perkin CPU Architecture:Any
Tags: bfsm_2007_10_18

[1 Sep 2007 22:33] Matthew Montgomery
Description:
$ ./scripts/mysql_install_db --defaults-file=./my.cnf 
Neither host 'desktop' nor 'localhost' could be looked up with
/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option

This is caused by not having set extra_bindir.

This part confused me:  

224 # Path to MySQL installation directory
225 if test -z "$basedir" -a "$source_install" = 0
226 then
227   basedir="."
228   bindir="./bin"
229   extra_bindir="$bindir"
230   mysqld="./bin/mysqld"
231   pkgdatadir="./share"
232 else
...
238     if test -z "$basedir"
239     then
240       # We come here when source-install is given
241       bindir="$basedir/bin"
242       extra_bindir="$bindir"
243     fi

The script appears to set bindir and extra_bindir = '/bin' when $basedir is not set in the script.  If it has zero length why append it to /bin?  

However, basedir is specified in the my.cnf that is used in the --defaults-file option so I hit this section and no extra_bindir is defined.

245     if test -x "$mysqld"
246     then
247       pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql scripts`
248       if test -z "$pkgdatadir"
249       then
250         missing_in_basedir fill_help_tables.sql
251        exit 1
252       fi
253     else

How to repeat:
.

Suggested fix:
245     if test -x "$mysqld"
246     then
247       extra_bindir="$bindir"  ## Set extra_bindir
248       pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql scripts`
249       if test -z "$pkgdatadir"
250       then
251         missing_in_basedir fill_help_tables.sql
252        exit 1
253       fi
254     else
[6 Sep 2007 15:07] Sasha V
In mysql-6.0-falcon

insert line 246:
extra_bindir="$bindir"  ## Set extra_bindir

and in bin/mysql_install_db
lines 320 and 323
change from:
-------------------------
# Check if hostname is valid
if test "$windows" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then
  resolved=`resolveip $hostname 2>&1`
  if [ $? -ne 0 ]
  then
    resolved=`resolveip localhost 2>&1`
--------------------------

to:
-------------------------
# Check if hostname is valid
if test "$windows" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then
  resolved=`$extra_bindir/resolveip $hostname 2>&1`
  if [ $? -ne 0 ]
  then
    resolved=`$extra_bindir/resolveip localhost 2>&1`
--------------------------
[20 Sep 2007 8:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/34415

ChangeSet@1.2560, 2007-09-20 10:06:36+02:00, jonathan@bagpuss.adsl.perkin.org.uk +1 -0
  Remove the --source-install option and instead make use of --srcdir
  to install system tables directly from the source tree (useful for
  testing purposes).  This helps clean the script up a lot and clarify
  the three possible ways the script can be called (using compiled-in
  paths, passing --basedir pointing to alternative install location,
  or --srcdir).  Include further tidying as well.
  
  This fixes bug#30759.
[26 Sep 2007 15:34] Alexander Rubin
This bug is the same: http://bugs.mysql.com/bug.php?id=31086
[26 Sep 2007 16:20] Daniel Fischer
To clarify:

This happens when "basedir" is specified, either in a my.cnf, or on the command line.

Running the configure script included in the package, or running mysql_install_db --no-defaults manually, doesn't show the bug.

The easiest way to reproduce it is running "mysql_install_db --no-defaults --basedir=." in an extracted tarball.
[28 Sep 2007 15:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/34651

ChangeSet@1.2606, 2007-09-28 17:33:14+02:00, joerg@trift2. +1 -0
  Preliminary fix for
     Bug #30759  	mysql_install_db fails to set $extra_bindir properly in all cases.
[5 Oct 2007 17:57] Bugs System
Pushed into 5.1.23-beta
[8 Nov 2007 12:43] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37326

ChangeSet@1.2606, 2007-11-08 13:43:40+01:00, jperkin@production.mysql.com +1 -0
  Remove the --source-install option and instead make use of --srcdir
  to install system tables directly from the source tree (useful for
  testing purposes).  This helps clean the script up a lot and clarify
  the three possible ways the script can be called (using compiled-in
  paths, passing --basedir pointing to alternative install location,
  or --srcdir).  Include further tidying as well.
    
  This fixes bug#30759.
[21 Nov 2007 18:53] Bugs System
Pushed into 5.1.23-rc
[21 Nov 2007 18:53] Bugs System
Pushed into 6.0.4-alpha
[3 Dec 2007 9:52] MC Brown
A note has been added to the 5.1.23 and 6.0.4 changelogs: 

Incompatible Change: The mysql_install_db script could fail to locate some components (including resolveip) during execution if the --basedir option was specified on the command-line or within the my.cnf file. This was due to a conflict when comparing the compiled-in values and the supplied values.

The --source-install command-line option to the script has been removed and replaced with the --srcdir option. mysql_install_db now locates components either using the compiled-in options, the --basedir option or --srcdir option.
[7 Feb 2008 11:58] Sveta Smirnova
Bug #34377 was marked as duplicate of this one