Bug #19504 my_print_defaults prints output twice
Submitted: 3 May 2006 7:35 Modified: 14 Jul 2006 15:00
Reporter: Oden Eriksson Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.21 OS:Linux (Linux 2.6.x)
Assigned to: CPU Architecture:Any

[3 May 2006 7:35] Oden Eriksson
Description:
Hello.

I just noticed an error when packaging the Mandriva RPM package with MySQL-5.0.21. We use this line to determine where the datadir is:

my_print_defaults mysqld | grep '^--datadir=' | cut -d= -f2

But now the output from my_print_defaults is given twice:

[oden@oe ~]$ my_print_defaults mysqld
--user=mysql
--datadir=/var/lib/mysql
--port=3306
--socket=/var/lib/mysql/mysql.sock
--pid-file=/var/run/mysqld/mysqld.pid
--skip-locking
--key_buffer=16M
--max_allowed_packet=1M
--table_cache=64
--sort_buffer_size=512K
--net_buffer_length=8K
--read_buffer_size=256K
--read_rnd_buffer_size=512K
--myisam_sort_buffer_size=8M
--old_passwords
--skip-networking
--log-bin=mysql-bin
--server-id=1
--user=mysql
--datadir=/var/lib/mysql
--port=3306
--socket=/var/lib/mysql/mysql.sock
--pid-file=/var/run/mysqld/mysqld.pid
--skip-locking
--key_buffer=16M
--max_allowed_packet=1M
--table_cache=64
--sort_buffer_size=512K
--net_buffer_length=8K
--read_buffer_size=256K
--read_rnd_buffer_size=512K
--myisam_sort_buffer_size=8M
--old_passwords
--skip-networking
--log-bin=mysql-bin
--server-id=1

In every MySQL version up to 5.0.20a this has worked. I have no ~/.my.cnf file but one /etc/my.cnf file. In this file the datadir exists once. If I use the --defaults-file switch I get the correct behaviour.

[oden@oe ~]$ my_print_defaults --defaults-file=/etc/my.cnf mysqld
--user=mysql
--datadir=/var/lib/mysql
--port=3306
--socket=/var/lib/mysql/mysql.sock
--pid-file=/var/run/mysqld/mysqld.pid
--skip-locking
--key_buffer=16M
--max_allowed_packet=1M
--table_cache=64
--sort_buffer_size=512K
--net_buffer_length=8K
--read_buffer_size=256K
--read_rnd_buffer_size=512K
--myisam_sort_buffer_size=8M
--old_passwords
--skip-networking
--log-bin=mysql-bin
--server-id=1

How to repeat:
[oden@oe ~]$ my_print_defaults mysqld | grep '^--datadir=' | cut -d= -f2
/var/lib/mysql
/var/lib/mysql

[oden@oe ~]$ my_print_defaults --defaults-file=/etc/my.cnf mysqld | grep '^--datadir=' | cut -d= -f2
/var/lib/mysql
[12 May 2006 11:31] Valeriy Kravchuk
Thank you for a problem report. Did you compile MySQL 5.0.21 from sources? If yes, please, specify the exact configure options used.
[12 May 2006 14:57] Oden Eriksson
We build two versions, one with NDB and other stuff and one without. And yes we use the source to build MySQL.

Here's the plain one:

./configure --build=i586-mandriva-linux-gnu --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/us
r/lib --libexecdir=/usr/lib --localstatedir=/var/lib --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --prefix=/ --exec-prefix=/usr --libexecdir=/usr/sbin --libdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/share/info --includedir=/usr/include --mandir=/usr/share/man --enable-shared --with-extra-charsets=complex --enable-assembler --enable-local-infile --enable-large-files=yes --enable-largefile=yes --without-readline --without-libwrap --without-mysqlfs --with-openssl --with-berkeley-db --with-innodb --with-big-tables --enable-thread-safe-client --without-debug --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --disable-shared --with-comment='Mandriva Linux - MySQL Standard Edition (GPL)' --without-embedded-server --without-berkeley-db --without-vio

Here's the Max version:

./configure --build=i586-mandriva-linux-gnu --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/lib --localstatedir=/var/lib --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --prefix=/ --exec-prefix=/usr --libexecdir=/usr/sbin --libdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/share/info --includedir=/usr/include --mandir=/usr/share/man --enable-shared --with-extra-charsets=complex --enable-assembler --enable-local-infile --enable-large-files=yes --enable-largefile=yes --without-readline --without-libwrap --without-mysqlfs --with-openssl --with-berkeley-db --with-innodb --with-big-tables --enable-thread-safe-client --without-debug --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --with-comment='Mandriva Linux - MySQL Max Edition (GPL)' --with-embedded-server --with-archive-storage-engine --with-csv-storage-engine --with-example-storage-engine --with-blackhole-storage-engine --with-federated-storage-engine --with-big-tables --with-ndbcluster --with-ndb-shm --with-ndb-docs --with-server-suffix='-Max'
[21 May 2006 10:52] Valeriy Kravchuk
You have --datadir=/usr/share repeated twice in both your configure command lines... Please, remove one of the entries and check, if --datadir will appear twice in results after that.
[23 May 2006 19:36] Oden Eriksson
I just tried this but got the same behaviour.
[14 Jun 2006 15:00] Valeriy Kravchuk
Sorry, but, please, send the results of:

grep -n datadir /etc/my.cnf

Just to be sure.
[14 Jul 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[13 Aug 2007 17:44] Jason Shuler
I saw this problem when I has MYSQL_HOME set as well as having /etc/my.cnf

It was reading the file twice.