visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: Problems with MySQL Start-Stop Script


By: maxhugen U.S.A.  Date: 02/08/2003 00:00:00  English  Points: 250 Status: Answered
Quality : Excellent
I have installed MySQL 4.0.14 on a RedHat 7.2 server. I copied the script mysql-server to /etc/rc.d/init.d/mysql as per instructions, but when I try to run the script I get the error:

bash: ./mysql: bad interpreter: No such file or directory

The only change I made to this file was to change the datadir from /usr/local/mysql/data to /home/mysql/data. I have been able to start mysql by starting the daemon directly, using the commands:

# cd /usr/local/mysql/bin/
# su mysql
# ./mysqld start
030803 11:14:17 InnoDB: Started
./mysqld: ready for connections.
Version: '4.0.14-standard' socket: '/tmp/mysql.sock' port: 3306

So, something is definitely wrong with my start script (/etc/rc.d/init.d/mysql ), but I have no idea how to debug it. I did try the sample script "mysql.server" just as it is, except renaming to mysql, but I got the same result.

I've read so much from the manual, and sources on the Internet, that my head is just going around in circles! Can anyone pls point me in the right direction, so I don't wander in the wilderness for 40 years? :o)


MTIA, Max Hugen


By: wskoczen Date: 02/08/2003 14:26:00 English  Type : Answer
It means that somewhere in the script code a file or directory referenced doesn't exist;
Try and split the script into smaller parts to find the extact point, or execute step by step all the instructions within from the shell.
Good Luck
Wesley
By: VGR Date: 03/08/2003 19:15:00 English  Type : Assist
naaaaaaa

it's just that /usr/local/mysql/bin/ isn't in your PATH :D or that your script incorrectly changed working directory. Try locating the "mysqld" executable first, then make sure your start script does a correct "cd" and has the rights to do so... Don't forget a script can't be suid-ed to "root" level


anyway, use the standard safe_mysql / mysql_safe script
By: slyong Date: 03/08/2003 20:16:00 English  Type : Assist
It would be helpful if you could put the /etc/rc.d/init.d/mysql script here.. (hopefully it is short ;).
By: spc_123 Date: 11/08/2003 09:09:00 English  Type : Assist
I'm running Mandrake 9.1 linux and had some problems myself. Here's what I did to resolve the auto-start. First, assuming that MySQL is able to be brought up from the mysql_install_dir: /usr/local/mysql# . bin/mysqld_safe --user=mysql &
If everything works fine, and the my.cnf in the /etc dir is ok, then copy the mysql.server to /etc/init.d
Vi the file to make sure the paths are correct. Check the rc*.d files in /etc. I had rc0-6 in my /etc directory. In my case, rc0.d and rc6.d are both used for shutdown. Cd to /etc/rc0.d and create a symbolic link: ln -s /etc/init.d/mysql.server K01mysql.
This will allow MySQL to shut down gracefully when the system shuts down.

For Start-up: the manual says to create a symbolic link from /etc/rc3.d to the mysql.server. This may work for Unix, but in my case, I had to create it in rc5.d in order for it to work on boot.

here's the file:
#!/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

# MySQL daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 3 5
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO

# If you install MySQL on some other places than /usr/local/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
# [mysqld]
# basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
# and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
# below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

basedir=/usr/local/mysql/

# The following variables are only set for letting mysql.server find things.

# Set some defaults
datadir=/usr/local/mysql/data/
pid_file=
if test -z "$basedir"
then
basedir=/usr/local/mysql/
bindir=./bin
else
bindir="$basedir/bin"
fi

PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
export PATH

if test -z "$pid_file"
then
pid_file=$datadir/`/bin/hostname`.pid
else
case "$pid_file" in
/* ) ;;
* ) pid_file="$datadir/$pid_file" ;;
esac
fi

mode=$1 # start or stop

parse_arguments() {
for arg do
case "$arg" in
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
esac
done
}

# Get arguments from the my.cnf file,
# groups [mysqld] [mysql_server] and [mysql.server]
if test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
print_defaults="$bindir/mysql_print_defaults"
else
# Try to find basedir in /etc/my.cnf
conf=/etc/my.cnf
print_defaults=
if test -r $conf
then
subpat='^[^=]*basedir[^=]*=\(.*\)$'
dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
for d in $dirs
do
d=`echo $d | sed -e 's/[ ]//g'`
if test -x "$d/bin/my_print_defaults"
then
print_defaults="$d/bin/my_print_defaults"
break
fi
if test -x "$d/bin/mysql_print_defaults"
then
print_defaults="$d/bin/mysql_print_defaults"
break
fi
done
fi

# Hope it's in the PATH ... but I doubt it
test -z "$print_defaults" && print_defaults="my_print_defaults"
fi

parse_arguments `$print_defaults mysqld mysql_server mysql.server`

# Safeguard (relative paths, core dumps..)
cd $basedir

case "$mode" in
'start')
# Start daemon

if test -x $bindir/mysqld_safe
then
# Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade.
$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file &
# Make lock for RedHat / SuSE
if test -w /var/lock/subsys
then
touch /var/lock/subsys/mysql
fi
else
echo "Can't execute $bindir/mysqld_safe from dir $basedir"
fi
;;

'stop')
# Stop daemon. We use a signal here to avoid having to know the
# root password.
if test -s "$pid_file"
then
mysqld_pid=`cat $pid_file`
echo "Killing mysqld with pid $mysqld_pid"
kill $mysqld_pid
# mysqld should remove the pid_file when it exits, so wait for it.

sleep 1
while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
do
[ -z "$flags" ] && echo "Wait for mysqld to exit\c" || echo ".\c"
flags=a$flags
sleep 1
done
if [ -s $pid_file ]
then echo " gave up waiting!"
elif [ -n "$flags" ]
then echo " done"
fi
# delete lock for RedHat / SuSE
if test -f /var/lock/subsys/mysql
then
rm /var/lock/subsys/mysql
fi
else
echo "No mysqld pid file found. Looked for $pid_file."
fi
;;

'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
$0 stop
$0 start
;;

*)
# usage
echo "Usage: $0 start|stop|restart"
exit 1
;;
esac


Do register to be able to answer

EContact
browser fav
page generated in 305.861950 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page