Bug #17979 my_print_defaults/mysql_install_db ignore [mysqld-X.Y] sections in option files
Submitted: 6 Mar 2006 18:29 Modified: 28 Nov 2006 22:30
Reporter: Geert Vanderkelen Email Updates:
Status: Patch approved Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: CPU Architecture:Any

[6 Mar 2006 18:29] Geert Vanderkelen
Description:

The my_print_defaults tool doesn't care about for example [mysqld-5.0] when the mysqld is version 5.0. mysqld (the executable) doesn't ignore it, so I guess my_print_defaults shouldn't either?

Executing 
  ./bin/my_print_defaults --defaults-file=~/.my.cnf mysqld mysqld-5.0
give good results though.

Maybe the shell scripts only need to be changed to include the release specific sections.

How to repeat:

A script like mysql_install_db using my_print_defaults gives unexpected results if one has a setup like:

(in ~/.my.cnf, note no [mysqld] section)
[mysqld-5.0]
datadir=/var/mysql/50

[mysqld-5.1]
datadir=/var/mysql/51

cd /usr/local/mysql50/
./scripts/mysql_install_db --defaults-file=~/.my.cnf

You would expect the datadir /var/mysql/50 to be used, but instead
   /usr/local/mysql/data 
the default, is used.

Suggested fix:
Here a Patch for mysql_install_db. I think it's better to fix my_print_defaults though, to make it work like mysqld daemon works. The awk solution is ugly, to get version..

76,96d75
< if test -x ./bin/mysqld
< then
<   mysqld_bin="./bin/mysqld"
< elif test -x ./sbin/mysqld
< then
<   mysqld_bin="./sbin/mysqld"
< elif test -x ./libexec/mysqld
< then
<   mysqld_bin="./libexec/mysqld"
< else
<   mysqld_bin=""
< fi
< 
< if [ mysqld_bin != "" ]
< then
<   v=`./bin/mysqld --version | awk '{ print $3 }' | awk -F. '{ print $1 "." $2}'`
<   mysqld_version="mysqld-$v"
< else
<   mysqld_version=""
< fi
< 
106c85
< echo $print_defaults $defaults mysqld $mysqld_version mysql_install_db
---
> echo $print_defaults $defaults mysqld mysql_install_db
[6 Mar 2006 18:31] Geert Vanderkelen
Verified with 5.0 and 5.1 on Linux.
[4 Aug 2006 11: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/10046

ChangeSet@1.2537, 2006-08-04 04:15:37-07:00, igreenhoe@anubis.greendragongames.com +1 -0
  Fix for bug #18579 (mysql_install_db only creates database for first
  instance in my.cnf)
  
  Fix for bug #17979 (my_print_defaults/mysql_install_db ignore
  [mysqld-X.Y] sections in option files)
  
  Problem:  Short of editing the my.cnf file or providing all of the
  relevant options on the command line, there was no way of creating a
  database for anything other than what was listed in the
  "[mysqld]" group.
  
  Solution:  Added command argument to mysql_install_db to direct it to
  use "[mysqld2]", etc., groups ( --defaults-group-suffix=# ).  This is
  the same argument used in the server to select such behavior.
  
  In addition, support was added for the [mysql-VERSION] group.
  
  Please note that the script does not attempt to create multiple
  databases at once.  If necessary, a wrapper script can be written to
  do this.
[7 Aug 2006 22:15] 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/10132

ChangeSet@1.2537, 2006-08-07 15:14:53-07:00, igreenhoe@anubis.greendragongames.com +1 -0
  Fix for bug #17979 (my_print_defaults/mysql_install_db ignore
  [mysqld-X.Y] sections in option files)
  
  Problem: As stated.
  
  Solution: Modify scripts/mysql_install_db.sh
  Patch is for 4.1 since problem exists in that version as well.
[14 Mar 2014 12:06] Hartmut Holzgraefe
Still unfixed in 5.6/5.7 in both the .sh and .pl versions ...