Commit 271cf5ed authored by unknown's avatar unknown
Browse files

Merge mysql.com:/home/jimw/my/mysql-5.1-old-scripts

into  mysql.com:/home/jimw/my/mysql-5.1-clean

parents b538c352 2cf34e52
Loading
Loading
Loading
Loading
+0 −53
Original line number Diff line number Diff line

use mysql;

--
-- merging `host` table and `db`
--

UPDATE IGNORE host SET Host='%' WHERE Host='';
DELETE FROM host WHERE Host='';

INSERT IGNORE INTO db (User, Host, Select_priv, Insert_priv, Update_priv,
    Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv,
    Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv)
  SELECT d.User, h.Host,
    (d.Select_priv           = 'Y' || h.Select_priv           = 'Y') + 1,
    (d.Insert_priv           = 'Y' || h.Select_priv           = 'Y') + 1,
    (d.Update_priv           = 'Y' || h.Update_priv           = 'Y') + 1,
    (d.Delete_priv           = 'Y' || h.Delete_priv           = 'Y') + 1,
    (d.Create_priv           = 'Y' || h.Create_priv           = 'Y') + 1,
    (d.Drop_priv             = 'Y' || h.Drop_priv             = 'Y') + 1,
    (d.Grant_priv            = 'Y' || h.Grant_priv            = 'Y') + 1,
    (d.References_priv       = 'Y' || h.References_priv       = 'Y') + 1,
    (d.Index_priv            = 'Y' || h.Index_priv            = 'Y') + 1,
    (d.Alter_priv            = 'Y' || h.Alter_priv            = 'Y') + 1,
    (d.Create_tmp_table_priv = 'Y' || h.Create_tmp_table_priv = 'Y') + 1,
    (d.Lock_tables_priv      = 'Y' || h.Lock_tables_priv      = 'Y') + 1
  FROM db d, host h WHERE d.Host = '';

UPDATE IGNORE db SET Host='%' WHERE Host = '';
DELETE FROM db WHERE Host='';

TRUNCATE TABLE host;

--
-- Adding missing users to `user` table
--
-- note that invalid password causes the user to be skipped during the
-- load of grand tables (at mysqld startup) thus three following inserts
-- do not affect anything

INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM db;
INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM tables_priv;
INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM columns_priv;

SELECT DISTINCT
"There are user accounts with the username 'PUBLIC'. In the SQL-1999
(or later) standard this name is reserved for PUBLIC role and can
not be used as a valid user name. Consider renaming these accounts before
upgrading to MySQL-5.0.
These accounts are:" x
FROM user WHERE user='PUBLIC';
SELECT CONCAT(user,'@',host) FROM user WHERE user='PUBLIC';

scripts/mysqld_safe-watch.sh

deleted100644 → 0
+0 −150
Original line number Diff line number Diff line
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
#
# scripts to start the MySQL demon and restart it if it dies unexpectedly
#
# This should be executed in the MySQL base directory if you are using a
# binary installation that has other paths than you are using.
#
# mysql.server works by first doing a cd to the base directory and from there
# executing mysqld_safe

# Check if we are starting this relative (for the binary release)
if test -f ./data/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
 -x ./bin/mysqld
then
  MY_BASEDIR_VERSION=`pwd`		# Where bin, share and data is
  DATADIR=$MY_BASEDIR_VERSION/data	# Where the databases are
  ledir=$MY_BASEDIR_VERSION/bin		# Where mysqld are
# Check if this is a 'moved install directory'
elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
 -x ./libexec/mysqld
then
  MY_BASEDIR_VERSION=`pwd`		# Where libexec, share and var is
  DATADIR=$MY_BASEDIR_VERSION/var	# Where the databases are
  ledir=$MY_BASEDIR_VERSION/libexec	# Where mysqld are
else
  MY_BASEDIR_VERSION=/usr/local/mysql
  DATADIR=/usr/local/mysql/var
  ledir=/usr/local/mysql/libexec
fi

hostname=`@HOSTNAME@`
pidfile=$DATADIR/$hostname.pid
log=$DATADIR/$hostname.log
err=$DATADIR/$hostname.err
lockfile=$DATADIR/$hostname.lock

#
# If there exists an old pid file, check if the demon is already running
# Note: The switches to 'ps' may depend on your operating system

if test -f $pidfile
then
  PID=`cat $pidfile`
  if /bin/kill -0 $PID
  then
    if /bin/ps -p $PID | 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` >> $log
      exit 1;
    fi
  fi
  rm -f $pidfile
  if test -f $pidfile
  then
    echo "Fatal error: Can't remove the pid file: $pidfile"
    echo "Fatal error: Can't remove the pid file: $pidfile at " `date` >> $log
    echo "Please remove it manually and start $0 again"
    echo "mysqld demon not started"
    exit 1;
  fi
fi

echo "Starting mysqld demon with databases from $DATADIR"

#Default communication ports
#MYSQL_TCP_PORT=3306
if test -z "$MYSQL_UNIX_PORT"
then
  MYSQL_UNIX_PORT="/tmp/mysql.sock"
  export MYSQL_UNIX_PORT    
fi
#export MYSQL_TCP_PORT

# Does this work on all systems?
#if type ulimit | grep "shell builtin" > /dev/null
#then
#  ulimit -n 256 > /dev/null 2>&1		# Fix for BSD and FreeBSD systems
#fi

echo "mysqld started on " `date` >> $log
bin/zap -f $lockfile < /dev/null > /dev/null 2>&1
rm -f $lockfile
$MY_BASEDIR_VERSION/bin/watchdog_mysqld $lockfile $pidfile $MY_BASEDIR_VERSION/bin $DATADIR 3 10 >> $err 2>&1 &
restart_pid=$!

while true
do
  rm -f $MYSQL_UNIX_PORT $pidfile	# Some extra safety
  lockfile -1 -r10 $lockfile >/dev/null 2>&1
  if test "$#" -eq 0
  then
    nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \
     --skip-locking >> $err 2>&1 &
  else
    nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \
     --skip-locking "$@" >> $err 2>&1 &
  fi
  pid=$!
  rm -f $lockfile
  wait $pid;

  lockfile -1 -r10 $lockfile >/dev/null 2>&1
  rm -f $lockfile
  if test ! -f $pidfile			# This is removed if normal shutdown
  then
    break;
  fi
  if true
  then
    # Test if one proces was hanging.
    # This is only a fix for Linux (running as base 3 mysqld processes)
    # but should work for the rest of the servers.
    # The only thing is ps x => redhat 5 gives warnings when using ps -x.
    # kill -9 is used or the proces won't react on the kill.
    numofproces=`ps x | grep -v "grep" | grep -c $ledir/mysqld`
    echo -e "\nNumber of processes running now: $numofproces" | tee -a $log
    I=1
    while test "$I" -le "$numofproces"
    do 
      PROC=`ps x | grep $ledir/mysqld | grep -v "grep" | tail -1` 
	for T in $PROC
	do
	  break
	done
	#    echo "TEST $I - $T **"
	if kill -9 $T
	then
	  echo "mysqld proces hanging, pid $T - killed" | tee -a $log
	else 
	  break
	fi
	I=`expr $I + 1`
    done
  fi
  echo "mysqld restarted" | tee -a $log
  # Check all tables and repair any wrong tables.
  $MY_BASEDIR_VERSION/bin/isamchk -sf $DATADIR/*/*.ISM >> $err 2>&1
done
if test $restart_pid -gt 0
then
  kill $restart_pid > /dev/null 2>&1
  sleep 1;
  kill -9 $restart_pid > /dev/null 2>&1
fi

echo -n "mysqld ended on " `date` >> $log
echo "mysqld demon ended"

sql/watchdog_mysqld

deleted100755 → 0
+0 −126
Original line number Diff line number Diff line
#!/usr/bin/perl
# Copyright (C) 1979-1998 TcX AB & Monty Program KB & Detron HB
#
# This software is distributed with NO WARRANTY OF ANY KIND.  No author or
# distributor accepts any responsibility for the consequences of using it, or
# for whether it serves any particular purpose or works at all, unless he or
# she says so in writing.  Refer to the Free Public License (the "License")
# for full details.
#
# Every copy of this file must include a copy of the License, normally in a
# plain ASCII text file named PUBLIC.	The License grants you the right to
# copy, modify and redistribute this file, but only under certain conditions
# described in the License.  Among other things, the License requires that
# the copyright notice and this notice be preserved on all copies. */

#
# This scripts is started by safe_mysqld. It checks that MySQL is alive and
# working ( = answering to ping).  If not, force mysqld down, check all
# tables and let safe_mysqld restart the server.
#
# For this to work, you should have procmail installed as the commands
# 'lockfile' and is used to sync with safe_mysqld
#
# NOTE:  You should only use this script as a last resort if mysqld locks
# up unexpectedly in a critical application and you have to get it to
# work temporarily while waiting for a solution from mysql@tcx.se or
# mysql-support@tcx.se


use POSIX "waitpid";

# Arguments from safe_mysqld

if ($#ARGV != 4)
{
  print "$0:  Wrong number of arguments. Aborting\n";
  exit 1;
}

$lock_file=shift;		# File to lock to sync with safe_mysqld
$pid_file=shift;		# Pid file used by mysqld
$bin_dir=shift;			# Directory where mysqladmin is
$test_timeout=shift;		# Time between testing if mysqld is alive
$wait_timeout=shift;		# How long time to wait for ping

$|=1;				# autoflush

# Check that mysqld has started properly

for ($i=1 ; $i < 10 ; $i ++)
{
  last if (-e $pid_file);
}
sleep(1);			# If server has just created the file
if (($mysqld_pid=`cat $pid_file`) <= 0)
{
  print "$0: Error: Invalid pidfile (contains '$mysqld_pid'). Aborting\n";
}
  
# Start pinging mysqld

for (;;)
{
  sleep($test_timeout);		# Time between tests
  `lockfile $lock_file > /dev/null 2>&1`;	# Sync with safe_mysqld
  if (($pid=fork()) == 0)
  {
    setpgrp(0,0);
    exit(int(system("$bin_dir/mysqladmin -w status > /dev/null")/256));
  }
  for ($i=0; ($res=waitpid(-1,&POSIX::WNOHANG)) == 0 && $i < $wait_timeout ; $i++)
  {
    sleep(1);
  }
  if ($res == 0)
  {
    print "$0: Warning: mysqld hanged;  Killing it so that safe_mysqld can restart it!\n";
    $mysqld_pid= `cat $pid_file`;
    if ($mysqld_pid <= 0)
    {
      print "$0: Error: Invalid pidfile (contains '$mysqld_pid'). Aborting\n";
      system("rm -f $lock_file");
      kill(-9,$pid);
      exit 1;
    }
    print "$0: Sending signal 15 to $mysqld_pid\n";
    kill(-15, $pid,$mysqld_pid); # Give it a last change to die nicely
    for ($i=0 ; $i < 5 ; $i++) { sleep(1); } # Wait 5 seconds (signal safe)
    waitpid(-1,&POSIX::WNOHANG);
    if (kill(0,$pid,$mysqld_pid) != 0)
    {
      print "$0: Sending signal 9 to $mysqld_pid\n";
      kill(-9,$pid,$mysqld_pid);	# No time to be nice anymore
      sleep(2);				# Give system time to clean up
      waitpid(-1,&POSIX::WNOHANG);
      if (kill(0,$mysqld_pid) != 0)
      {
	print "$0: Warning: mysqld don't want to die. Aborting\n";
	system("rm -f $lock_file");
	exit 1;
      }
    }
    # safe_mysqld will not restart mysqld if the pid file doesn't exists
    system("rm $pid_file");
    system("touch $pid_file");
  }
  elsif ($res == -1)
  {
    print "$0: Error: waitpid returned $res when wating for pid $pid\nPlease verify that $0 is correct for your system\n";
    system("rm -f $lock_file");
    exit 1;
  }
  else
  {
    $exit_code=int($?/256);
    if ($exit_code != 0)
    {
      print "$0: Warning: mysqladmin returned exit code $exit_code\n";
    }
    else
    {
      #print "mysqld is alive and feeling well\n";
    }
  }
  system("rm -f $lock_file");		# safemysqld will now take over
}