Bug #4659 Some client programs only look in /usr/local/mysql/bin/ for binaries
Submitted: 20 Jul 2004 22:05 Modified: 3 Aug 2004 17:57
Reporter: philip antoniades Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.3 OS:Linux (Linux)
Assigned to: Matthias Leich CPU Architecture:Any

[20 Jul 2004 22:05] philip antoniades
Description:
Some of the command-line client programs do not check any config (my.cnf) files, but only look for necessary binaries in /usr/local/mysql/. This prevents large companies from using the product in accordance with corporate standards. I have found this to be the case in:
safe_mysqld 
mysqlaccess

How to repeat:
Different tools fail in different ways. 

safe_mysqld only allows itself to be executed as './bin/safe_mysqld' or '/usr/local/mysql/bin/safe_mysqld' 

mysqlaccess recommends you edit it if you do not use /usr/local/mysql/ as your base directory:

[philip@ariadne philip]$ which mysql
/opt/mysql-standard-4.1.3-beta-pc-linux-i686/bin/mysql
[philip@ariadne philip]$ mysqlaccess

The MySQL client program </usr/local/mysql/bin/mysql> could not be found.
+ Check your path, or
+ edit the source of this script to point $MYSQL to the mysql client.
 
The MySQL dump program </usr/local/mysql/bin/mysqldump> could not be found.
+ Check your path, or
+ edit the source of this script to point $MYSQLDUMP to the mysqldump program.

Suggested fix:
Have all client scripts check for a common environment varaible where the distribution was unpacked or all read from a particular my.cnf (in /etc/ or ~/ )
[23 Jul 2004 4:38] Matthew Lord
mysqld_safe takes the --basedir option which allows you to run it from wherever and specify a 
different location that the compiled default.

mysqlaccess, however, has hardcoded paths to /usr/local/mysql/bin/mysql and /usr/local/mysql/
bin/mysqldump and it does not process a --basedir option.
[28 Jul 2004 19:12] Matthew Lord
mysqld_safe takes the basedir option but it doesn't use it to determine where mysqld is!

MY_PWD=`pwd`
# Check if we are starting this relative (for the binary release)
if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
 -x ./bin/mysqld
then
  MY_BASEDIR_VERSION=$MY_PWD            # Where bin, share and data are
  ledir=$MY_BASEDIR_VERSION/bin         # Where mysqld is
  DATADIR=$MY_BASEDIR_VERSION/data
  if test -z "$defaults"
  then
    defaults="--defaults-extra-file=$MY_BASEDIR_VERSION/data/my.cnf"
  fi
# Check if this is a 'moved install directory'
elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
 -x ./libexec/mysqld
then
  MY_BASEDIR_VERSION=$MY_PWD            # Where libexec, share and var are
  ledir=$MY_BASEDIR_VERSION/libexec     # Where mysqld is
  DATADIR=$MY_BASEDIR_VERSION/var
else
  MY_BASEDIR_VERSION=/usr/local/mysql
  DATADIR=/usr/local/mysql/var
  ledir=/usr/local/mysql/libexec
fi

We need to use the passed in basedir which is assigned to MY_BASEDIR_VERSION if it has a 
value.
[3 Aug 2004 17:57] Matthias Leich
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Thank you for taking the time to write to us, but this is not
a bug.

1. The report seems to be basically a description of the current
    behaviour if somebody moves a binary installation (configured
    and compiled for installation in /usr/local/mysql) to another
    destination. 
    It is possible to avoid some of the problems caused by such a
    move via tricky use of the command line options and option 
    files, but not all tools have such options.
    I would say the software works as intended/designed, but I
    also believe that the current properties do not fit to the 
    needs of certain customers.
    It would be nice if our software had a global and convenient 
    solution for such cases, because not all customers are able
    to install the software at default places like /usr/local/mysql .
    So your suggested fix is a big change request and should be
    thoroughly discussed, because it affects nearly all binaries
    and scripts.

2. The "mysqld_safe --basedir=.." problem
    The software works as designed, because 
   - the manual says in "5.1.3 The mysqld_safe Server Startup Script"
     mysqld_safe expects one of the following conditions to be true:
    * The server and databases can be found relative to the directory from which mysqld_safe
       is invoked.  ....
       This condition should be met if you execute mysqld_safe from your MySQL installation 
       directory (for example, `/usr/local/mysql' for a binary distribution).
    * If the server and databases cannot be found relative to the working directory, 
       mysqld_safe attempts to locate them by absolute pathnames. ....
       The actual locations are determined from the values configured into the distribution 
       at the time it was built. They should be correct if MySQL is installed in the location
       specified at configuration time. 
    "mysqld_safe" treats the "--basedir=.." option as an argument which should be
     only passed to the starting server as option. (There is a comment within the 
     mysqld_safe script that --basedir and some other options get passed explicitly 
     to mysqld).
     So the current mysqld_safe behaviour is similar to mysqld.
     Example: cd <BASEDIR1> ; libexec/mysqld --basedir=<BASEDIR2>
                or cd <BASEDIR1> ; libexec/mysqld with option file containing
                <BASEDIR2> will execute the binary <BASEDIR1>/libexec/mysqld
                for the server. The only effect is that the server will look into <BASEDIR2>
                if he needs some additional stuff for his work.

     I can modify "mysqld_safe" so, that if a basedir is assigned via command line
     parameter or option file all stuff( binaries etc.) will be taken from that assigned
     basedir. May be it will help some customers a little bit, but I have deep doubts
     - It is an absolute incompatible change of the semantics.
       Other customers may depend on the old semantics of "mysqld_safe".
     - The semantics of "mysqld_safe" and "mysqld" with assigned basedir 
       would then differ !! 
     - It provides no solution for the moved installation directory related 
       problems of other binaries and scripts.
     - I assume there will be only low or no acceptance for such an incomplete solution
       if I take into account the new problems created.
     These disadvantages are too big.

     Please excuse that I can give only a everything works as intended answer
     without solving your obvious problems.