Bug #35778 Syntax error in mysql_install_db script
Submitted: 2 Apr 2008 22:25 Modified: 16 May 2008 18:11
Reporter: David Eisner Email Updates:
Status: Can't repeat Impact on me:
Category:MySQL Server: Installing Severity:S2 (Serious)
Version:5.0.51a OS:Solaris (mysql-5.0.51a-solaris10-x86_64.pkg)
Assigned to: Sveta Smirnova
Tags: install, pkgadd, script

[2 Apr 2008 22:25] David Eisner
When installing the Solaris pkg, I noticed these errors:

[ verifying class <none> ]
## Executing postinstall script.
scripts/mysql_install_db: !: not found
scripts/mysql_install_db: !: not found
ERROR: 1004  Can't create file '/var/tmp//installIsay_J/#sql481e_1_0.frm' (errno: 13)
080402 17:55:03 [ERROR] Aborting

If I manually execute /opt/mysql/mysql/scripts/mysql_install_db, I see the first two errors repeated:

# ./mysql_install_db 
./mysql_install_db: !: not found
./mysql_install_db: !: not found
Installing MySQL system tables...

How to repeat:
Run either of these commands:
   /usr/sbin/pkgadd -d mysql-5.0.51a-solaris10-x86_64.pkg



Suggested fix:
It looks like there are a few syntax errors in the mysql_install_db Bourne shell script:

$ grep -n ! mysql_install_db
184:  if ! test -x "$print_defaults"
191:  if ! test -x "$print_defaults"
226:    if ! test -x "$mysqld"
252:  if test ! -f "$f"
273:if test ! -x "$mysqld"
275:  echo "FATAL ERROR: $mysqld not found!"
304:    echo "when specifying MySQL privileges !"
316:  if test ! -d $dir
321:  if test -w / -a ! -z "$user"

I believe "if ! test" in the first three cases should become "if test !" (as in the rest of the script).  If I make those edits, the script seems to work correctly.
[3 Apr 2008 8:05] Valerii Kravchuk
Thank you for a problem report. This is a known problem (see bug #35273, for example) in 5.0.51a and older versions. It is fixed in current sources though. Look, on today's 5.0-BK:

openxs@suse:~/dbs/5.0/bin> grep -n 'test' mysql_install_db
70:  if test "$in_rpm" -eq 0 -a "$cross_bootstrap" -eq 0
87:  if test "$1" = PICK-ARGS-FROM-ARGV
125:        if test -n "$pick_args"
153:    if test -f "$basedir/$dir/$file"
155:      if test -n "$return_dir"
182:if test -n "$basedir"
185:  if test ! -x "$print_defaults"
192:  if test ! -x "$print_defaults"
209:if test -z "$basedir"
218:  if test "$cross_bootstrap" -eq 0
221:    if test -z "$pkgdatadir"
227:    if test ! -x "$mysqld"
236:if test -z "$ldata"
242:if test -n "$srcdir"
253:  if test ! -f "$f"
261:if test "$cross_bootstrap" -eq 1
264:  if test -n "$srcdir" -a -f "$srcdir/sql/share/english/errmsg.sys"
273:# already tested above).
274:if test ! -x "$mysqld"
284:if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
309:if test "$ip_only" -eq 1
314:# Create database directories mysql & test
315:for dir in $ldata $ldata/mysql $ldata/test
317:  if test ! -d $dir
322:  if test -w / -a ! -z "$user"
328:if test -n "$user"
336:if test $cross_bootstrap -eq 1
372:  if test "$cross_bootstrap" -eq 0
386:    echo "which will also give you the option of removing the test"
393:    if test "$in_rpm" -eq 0
398:      echo "You can test the MySQL daemon with mysql-test-run.pl"
399:      echo "cd mysql-test ; perl mysql-test-run.pl"
404:    echo "The latest information about MySQL is available on the web at"
425:  echo "The latest information about MySQL is available on the web at"

So, "! test" is not used any more.
[2 May 2008 21:16] Sveta Smirnova
Reopened as at least one user found same issue in 5.0.58 package
[15 May 2008 18:10] Sveta Smirnova
Closed as duplicate of bug #31164
[15 May 2008 21:03] David Eisner
This is not a duplicate of Bug #31164.  Read both bugs carefully.  The problem here is a syntax error in the mysql_install_db script.  The problem there is pkgadd altering the value of $TMPDIR.  This is not the same issue.
[16 May 2008 18:11] Sveta Smirnova
Thank you for the report.

Another user, because whom i reopened the report, seen only "ERROR: 1004 Can't create file '/var/tmp//installkQayQg/#sqld75_1_0.frm' (errno: 13)" error, so I reclose the report as "Can't repeat".
[23 Mar 2009 21:40] David Elrod
There is a problem.
The script is creating a temporary directory.
    /var/tmp/install<something here>/#sql<more stuff>.frm

Every user will have different names here!

Please re-examine this!  We are seeing it in 5.0.74 (commercial).
[24 Mar 2009 7:08] Sveta Smirnova
David Elrod,

thank you for the feedback.

But what is the problem with creating different temporary files? Or do you have settings which don't allow to create sub directories in the /tmp directory?