Bug #33685 Unable to Start Mysql: Results in "line xxx: test: too many arguments"
Submitted: 4 Jan 2008 8:57 Modified: 18 Jun 17:07
Reporter: Sidney Lee
Status: Closed
Category:Client Severity:S2 (Serious)
Version:5.0.45, 5.1.22 OS:Any
Assigned to: Jim Winstead Target Version:
Tags: unable to start, too many arguments
Triage: Triaged: D4 (Minor)

[4 Jan 2008 8:57] Sidney Lee
Description:
When starting Mysql from the command line using ./bin/mysqld_safe, the message 

./bin/mysqld_safe: line 390: test: too many arguments 
080104 13:22:37 mysqld restarted

shows up.  The line number (390) changed to 485 and 543 when I tried installing version
5.1  Mysqld keeps on restarting and I am unable to connect to Mysql with a error 2002
message.  

How to repeat:
I actually am not sure how this bug can be viewed again.
[4 Jan 2008 9:04] Valeriy Kravchuk
What exact versions, 5.0.x and 5.1.x, do you use?
[4 Jan 2008 9:08] Sidney Lee
I'm using the mysql-5.0.45-osx10.4-i686.dmg.  I also tried installing the
mysql-5.1.22-rc-osx10.4-i686.tar.gz file without better luck.  I had MySQL working
yesterday and after rebooting my computer today I've been unable to use MySQL, even after
trying to remove the files (removing everything in Mac is quite difficult) and installing
again.
[4 Jan 2008 10:33] Sidney Lee
If anyone has the time or ability to help out that'd be fantastic...I'm working on a
website that's almost done and am planning on launching in a couple of days!

Thanks again.
[4 Jan 2008 10:34] Sidney Lee
Screenshot with error msg

Attachment: Picture 4.png (image/png, text), 21.51 KiB.

[9 Jan 2008 15:45] Hartmut Holzgraefe
What does your hostname as returned by the /bin/hostname program look like?
[9 Jan 2008 16:29] Sidney Lee
thanks for the reply.  it's just showing the name i set using 

sudo scutil --set HostName 

i.e. Sidney Lee's Computer
[9 Jan 2008 20:33] Hartmut Holzgraefe
patched mysqld_safe

Attachment: mysqld_safe (application/octet-stream, text), 12.84 KiB.

[9 Jan 2008 20:34] Hartmut Holzgraefe
Hi Sidney, 

please try the patched mysqld_safe i just uploaded to this bug,
it should solve the problem for 5.0.45
[10 Jan 2008 7:00] Sidney Lee
Hi, 

Thanks for the help.  I tried moving the patch to the base directory i.e.
/usr/local/mysql_5.0.45-osx10.4-i686 and running

patch -p0 < mysqld_safe  

without any successt.  If you could provide a little more detail in how I should patch
mysql I'd be very grateful.  As you can see, I'm quite new to this.

Thanks again.
[10 Jan 2008 11:26] Hartmut Holzgraefe
Sorry for the confusion, the attached file is a replacement for the original 5.0.45, not
just a patch file, so you should just copy it over the existing mysqld_safe
[12 Jan 2008 7:42] Sidney Lee
I replaced mysqld_safe in /bin with the patch you sent, but doing so doesn't appear to
have helped.
When I try running mysqld_safe after replacing the file, I'm getting a "cannot find
mysqld_safe" error message.
[12 Jan 2008 14:28] Hartmut Holzgraefe
Looks like you didn't set the "executable" flag on it?

  chmod a+x /path/to/mysqld_safe should help
[13 Feb 2008 1: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".
[17 Mar 2008 2:38] Guido Vacano
Hello. I had the same problem. My hostname was three words, changing it to one word (sudo
hostname xxxx) prior to installing MySQL solved the problem. I'm guessing spaces in the
hostname is the problem.
[17 Mar 2008 20:40] Hartmut Holzgraefe
Hello Guido, 

can you confirm that the replacement mysqld_safe in the "Files" section of this bug fixes
the problem for you?
[18 Apr 2008 1: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".
[23 May 2008 14:28] Hartmut Holzgraefe
patch against 5.0.51b mysqld_safe, adding extra quotes to lots of places to cope with
whitespace in hostnames:

--- scripts/mysqld_safe	2010-05-23 14:23:30.000000000 +0200
+++ /home/hartmut/new/mysqld_safe	2008-05-23 14:00:34.000000000 +0200
@@ -316,7 +316,7 @@
     USER_OPTION="--user=$user"
   fi
   # If we are root, change the err log to the right user.
-  touch $err_log; chown $user $err_log
+  touch "$err_log"; chown $user "$err_log"
   if test -n "$open_files"
   then
     ulimit -n $open_files
@@ -334,23 +334,23 @@
 #
 # If there exists an old pid file, check if the daemon is already running
 # Note: The switches to 'ps' may depend on your operating system
-if test -f $pid_file
+if test -f "$pid_file"
 then
-  PID=`cat $pid_file`
+  PID=`cat "$pid_file"`
   if /bin/kill -0 $PID > /dev/null 2> /dev/null
   then
     if /bin/ps p $PID | grep -v grep | grep $MYSQLD > /dev/null
     then    # The pid contains a mysqld process
       echo "A mysqld process already exists"
-      echo "A mysqld process already exists at " `date` >> $err_log
+      echo "A mysqld process already exists at " `date` >> "$err_log"
       exit 1
     fi
   fi
-  rm -f $pid_file
-  if test -f $pid_file
+  rm -f "$pid_file"
+  if test -f "$pid_file"
   then
     echo "Fatal error: Can't remove the pid file: $pid_file"
-    echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
+    echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> "$err_log"
     echo "Please remove it manually and start $0 again"
     echo "mysqld daemon not started"
     exit 1
@@ -377,23 +377,23 @@
 #  ulimit -n 256 > /dev/null 2>&1		# Fix for BSD and FreeBSD systems
 #fi
 
-echo "`date +'%y%m%d %H:%M:%S  mysqld started'`" >> $err_log
+echo "`date +'%y%m%d %H:%M:%S  mysqld started'`" >> "$err_log"
 while true
 do
-  rm -f $safe_mysql_unix_port $pid_file	# Some extra safety
+  rm -f $safe_mysql_unix_port "$pid_file"	# Some extra safety
   if test -z "$args"
   then
-    $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION
--datadir=$DATADIR $USER_OPTION --pid-file=$pid_file --skip-external-locking >> $err_log
2>&1
+    $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION
--datadir=$DATADIR $USER_OPTION --pid-file="$pid_file"  >> "$err_log" 2>&1
   else
-    eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION
--datadir=$DATADIR $USER_OPTION --pid-file=$pid_file --skip-external-locking $args >>
$err_log 2>&1"
+    eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION
--datadir=$DATADIR $USER_OPTION --pid-file="$pid_file"  $args >> "$err_log" 2>&1"
   fi
-  if test ! -f $pid_file		# This is removed if normal shutdown
+  if test ! -f "$pid_file"		# This is removed if normal shutdown
   then
     echo "STOPPING server from pid file $pid_file"
     break
   fi
 
-  if true && test $KILL_MYSQLD -eq 1
+  if false && test $KILL_MYSQLD -eq 1
   then
     # Test if one process was hanging.
     # This is only a fix for Linux (running as base 3 mysqld processes)
@@ -402,7 +402,7 @@
     # kill -9 is used or the process won't react on the kill.
     numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c
"pid-file=$pid_file"`
 
-    echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
+    echo -e "\nNumber of processes running now: $numofproces" | tee -a "$err_log"
     I=1
     while test "$I" -le "$numofproces"
     do 
@@ -415,16 +415,16 @@
       #    echo "TEST $I - $T **"
       if kill -9 $T
       then
-        echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
+        echo "$MYSQLD process hanging, pid $T - killed" | tee -a "$err_log"
       else 
         break
       fi
       I=`expr $I + 1`
     done
   fi
-  echo "`date +'%y%m%d %H:%M:%S'`  mysqld restarted" | tee -a $err_log
+  echo "`date +'%y%m%d %H:%M:%S'`  mysqld restarted" | tee -a "$err_log"
 done
 
-echo "`date +'%y%m%d %H:%M:%S'`  mysqld ended" | tee -a $err_log
-echo "" | tee -a $err_log
+echo "`date +'%y%m%d %H:%M:%S'`  mysqld ended" | tee -a "$err_log"
+echo "" | tee -a "$err_log"
[28 May 2008 10:59] Hartmut Holzgraefe
Actually affecting all unixoid platforms although Macs are most likely to be hitting this
due to Apples default host naming scheme, on other platforms you'll rarely see hostnames
with whitespace in them ...
[8 May 2:25] 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/73625

2890 Jim Winstead	2009-05-07
      mysqld_safe could generate filenames with spaces and then didn't properly
      quote them in later use. (Bug #33685, based on a patch by Hartmut Holzgraefe)
      modified:
        scripts/mysqld_safe.sh
[13 May 18:08] Jim Winstead
Patch queued to 5.1-bugteam, will be merged up from there.
[28 May 10:18] Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090528073639-yohsb4q1jzg7ycws) (version source
revid:jimw@mysql.com-20090512212719-mjc8fz4q3ewvr4yd) (merge vers: 5.1.35) (pib:6)
[30 May 4:30] Paul DuBois
Noted in 5.1.36 changelog.

mysqld_safe mishandled certain parameters if they contained spaces.

Setting report to NDI pending push into 6.0.x.
[17 Jun 21:25] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version
source revid:jimw@mysql.com-20090514020104-7u5cqf5cyywa8aks) (merge vers: 6.0.12-alpha)
(pib:11)
[18 Jun 17:07] Paul DuBois
Noted in 5.4.4 changelog.
[13 Aug 0:58] Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 4:15] Paul DuBois
Ignore previous comment about 5.4.2.
[26 Aug 15:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l)
(version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers:
5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 15:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc)
(version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers:
5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 15:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4)
(version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers:
5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 18:33] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr)
(version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers:
5.1.37-ndb-7.0.8) (pib:11)
[9 Oct 3:27] Paul DuBois
The 5.4 fix has been pushed to 5.4.2.
[9 Oct 3:28] Paul DuBois
The 5.4 fix has been pushed to 5.4.2.