Bug #7347 non-privileged user installation requires a fix
Submitted: 16 Dec 2004 9:24 Modified: 26 Jan 2005 23:58
Reporter: Patrick Guio Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:4.0.20-0 OS:Linux (Linux)
Assigned to: Jim Winstead

[16 Dec 2004 9:24] Patrick Guio
Description:
I have succesfully installed both MySQL client and server from rpm on a machine running linux (White Box Enterprise 3.0) as a non-privileged user and relocated *but* I needed to do a bug fix which I report here.
I used the following rpms:
MySQL-client-4.0.20-0.i386.rpm
MySQL-server-4.0.20-0.i386.rpm

After having built my local rpm database I can install those rpm with the following command
rpm -ivh --relocate /=$HOME MySQL-client-4.0.20-0.i386.rpm
and 
rpm -ivh --noscripts  --relocate /=$HOME MySQL-server-4.0.20-0.i386.rpm
so that installation scripts are not run and I can just run them manually with:

cd $HOME/usr
bin/mysql_install_db
bin/mysqladmin -u root password <mypasswd>
bin/mysqladmin -u root -h $HOST password <mypasswd>

but bin/mysql_install_db fails because it is looking for  but it is located in
 $HOME/usr/bin/mysqld.

I also needed to have a ~/.my.cnf with the following lines

[mysqld]
basedir=/home/patrick
datadir=/home/patrick/var/lib/mysql
socket=/home/patrick/var/lib/mysql/the.sock
port=3306
language=/home/patrick/usr/share/mysql/english

How to repeat:
Deinstall completely MySQL
mysqladmin -u root shutdown
rpm -e --nopreun MySQL-server-4.0.20-0.i386.rpm
rpm -e MySQL-client-4.0.20-0.i386.rpm

Suggested fix:
I looked into the file bin/mysql_install_db:78

if test -z "$basedir"
then
  basedir=/
  bindir=/usr/bin
  execdir=/usr/sbin
else
  bindir="$basedir/bin"
if test -x "$basedir/libexec/mysqld"
then
  execdir="$basedir/libexec"
elif test -x "/usr/sbin/mysqld"
then
  execdir="/usr/sbin"
else
  execdir="$basedir/bin"
fi
fi

mdata=$ldata/mysql

if test ! -x $execdir/mysqld
then
  if test "$IN_RPM" = "1"
  then
    echo "FATAL ERROR $execdir/mysqld not found!"
    exit 1
  else
    echo "Didn't find $execdir/mysqld"
    echo "You should do a 'make install' before executing this script"
    exit 1
  fi
fi

In my case
basedir=/home/patrick
and therefore the last statement is used
  execdir="$basedir/bin"
while it should be 
  execdir="$basedir/sbin"
so that $execdir/mysqld should be found
[11 Jan 2005 13:28] Aleksey Kishkin
tested on 4.0.21 and on 4.1.8. Error messages different but the sense is same - mysql_install_db assumes eighter source tree or already installed mysql into usual path - /usr/bin
[14 Jan 2005 18:45] Jim Winstead
Fixed in the 4.0 tree.
[26 Jan 2005 23:58] Paul Dubois
Mentioned in 4.0.24 change notes.