Bug #41828 mysql_install_db misses mysqld options when using --basedir
Submitted: 2 Jan 2009 12:50 Modified: 15 May 2009 23:35
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:5.1.30 OS:Linux
Assigned to: Jonathan Perkin CPU Architecture:Any

[2 Jan 2009 12:50] Geert Vanderkelen
Description:
The --language option is not set when using --basedir option, executing mysql_install_db. Could probably do it in option file, but maybe good to put it when --baesdir is given?

How to repeat:
Found this while experimenting with RPM --relocate, installing like this:
shell> rpm -ivh --relocate /=/other --nodeps --noscripts MySQL-client-community-5.1.30-0.rhel4.x86_64.rpm

This isn't really good way of doing it, I know this. But forcing my way through it:

shell> ./bin/mysql_install_db --datadir=/var/mysql2 --basedir=/other/usr
Installing MySQL system tables...
090102 13:34:04 [ERROR] Can't find messagefile '/usr/share/mysql/english/errmsg.sys'
090102 13:34:04 [ERROR] Aborting

Looking at the mysql_install_db source, the --language option is not passed to mysqld. It is when using mysql_install_db --srcdir:

 elif test -n "$basedir"
 then
   bindir="$basedir/bin"
   extra_bindir="$bindir"
   mysqld=`find_in_basedir mysqld libexec sbin bin`
   pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
   scriptdir="$basedir/scripts"

Suggested fix:
Add the mysqld_opt like this, or maybe there is a good reason why it's not there?

 elif test -n "$basedir"
 then
  bindir="$basedir/bin"
  extra_bindir="$bindir"
  mysqld=`find_in_basedir mysqld libexec sbin bin`
  mysqld_opt="--language=$basedir/share/mysql/english"
  pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
  scriptdir="$basedir/scripts"

Then it works.
Patch for latest 5.1 source tree:

=== modified file 'scripts/mysql_install_db.sh'
--- scripts/mysql_install_db.sh 2008-09-02 08:53:30 +0000
+++ scripts/mysql_install_db.sh 2009-01-02 12:44:57 +0000
@@ -240,6 +240,7 @@ then
   bindir="$basedir/bin"
   extra_bindir="$bindir"
   mysqld=`find_in_basedir mysqld libexec sbin bin`
+  mysqld_opt="--language=$basedir/share/mysql/english"
   pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
   scriptdir="$basedir/scripts"
 else
[2 Jan 2009 12:50] Geert Vanderkelen
Verified using 5.1.30, 5.1bzr
[2 Jan 2009 14:41] Geert Vanderkelen
To complete with a workaround:

 [mysqld]
 language=/opt/mysql/usr/share/mysql/english

And use mysql_update_db --defaults-file=/path/to/my.cnf ...
[5 Jan 2009 13:12] 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/62477

2706 Jonathan Perkin	2009-01-05
      bug#41828: mysql_install_db misses mysqld options when using --basedir
      
        * pass --languages= to mysqld when using --basedir
        * improve error messages when unable to find files in basedir
[5 Jan 2009 13:16] 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/62478

2707 Jonathan Perkin	2009-01-05
      bug#41828: mysql_install_db misses mysqld options when using --basedir
      
        * use full path to the errmsg.sys file in the failure message.
[6 Jan 2009 11:12] Bjørn Munch
I'm wondering about this change:

-------
@@ -210,6 +224,11 @@
 elif test -n "$basedir"
 then
   print_defaults=`find_in_basedir my_print_defaults bin extra`
+  if test -z "${print_defaults}"
+  then
+    cannot_find_file my_print_defaults $basedir/bin $basedir/extra
+    exit 1
+  fi
 else
   print_defaults="@bindir@/my_print_defaults"
 fi
-------

Right below this in the script is this test:

----
if test ! -x "$print_defaults"
then
  cannot_find_file "$print_defaults"
  exit 1
fi
----

This looks a bit redundant, could these tests be combined into one?
And should the latter cannot_find_file be updated?

Also, I think it looks odd with the redundant {} around the variable
names when the existing code doesn't use them. This applies to some
but not all of the changes.  But that's just a pet peeve of mine...
[6 Jan 2009 11:31] Jonathan Perkin
They used to be combined, however the problem is that find_in_basedir returns an empty string when no match is found, so the error message is empty.  I could use a single test and say "cannot find my_print_defaults" or similar but then information is lost which is useful to the user.  At present, the full path is printed for the srcdir and default options, and the filename with a list of searched directories is printed with the basedir option.  This gives the user the best chance of being able to diagnose any failure without having to dive into the code.

As for {} around variables, this is certainly a preference thing.  I prefer to be explicit and use them, as it leads to style inconsistency when you do need to have them, but you are right that at present they are not consistently used.  I'll change these back for now.
[6 Jan 2009 11:34] 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/62520

2708 Jonathan Perkin	2009-01-06
      bug#41828: mysql_install_db misses mysqld options when using --basedir
      
       * some shell style fixes
[6 Jan 2009 11:49] Bjørn Munch
Change looks fine, OK with me.
[6 Jan 2009 15:11] 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/62536

2706 Jonathan Perkin	2009-01-06
      bug#41828: mysql_install_db misses mysqld options when using --basedir
      
        * pass --languages to mysqld when using --basedir
        * improve error messages when unable to find files in basedir
[6 Jan 2009 15:21] 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/62538

2804 Jonathan Perkin	2009-01-06 [merge]
      Merge bug#41828 fix to mysql-6.0-build.
[7 Jan 2009 9:53] Jonathan Perkin
Fix pushed to mysql-5.1-build and upmerged to mysql-6.0-build.
[16 Jan 2009 11:20] Bugs System
Pushed into 5.1.32 (revid:joerg@mysql.com-20090115181125-29qdo615v9vkla0t) (version source revid:jperkin@sun.com-20090106150815-h73994vxstd7n0ub) (merge vers: 5.1.31) (pib:6)
[20 Jan 2009 18:56] Bugs System
Pushed into 6.0.10-alpha (revid:joro@sun.com-20090119171328-2hemf2ndc1dxl0et) (version source revid:timothy.smith@sun.com-20090116165151-xtp5e4z6qsmxyvy0) (merge vers: 6.0.10-alpha) (pib:6)
[14 Feb 2009 13:01] Bugs System
Pushed into 6.0.10-alpha (revid:matthias.leich@sun.com-20090212211028-y72faag15q3z3szy) (version source revid:timothy.smith@sun.com-20090207154714-9moby68i60j14r6w) (merge vers: 6.0.10-alpha) (pib:6)
[17 Feb 2009 14:57] Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 16:44] Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 18:21] Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090201210519-vehobc4sy3g9s38e) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)
[15 May 2009 23:35] Paul DuBois
Noted in 5.1.32, 6.0.10 changelogs.

mysql_install_db did not pass some relevant options to mysqld.