To have mysql to start at boot you need to inform the inetd (daemon) that
mysql should be launched at one of the 6 levels:
Use chkconfig to have mysql start in one of the level (2,3,4,5,6)
5 being X windows.
There are two ways to check that mysql will be loaded:
- 1 - by checking the file in /etc/rc.d/rcX.d (X being a number: 1,2,3,4,5,6)
- 2 - by executing chkconfig
execute the following to see if mysql runs at any level
/sbin/chkconfig --list | grep mysql
you should see at which level mysql is running.
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
If it is all off then execute:
/sbin/chkconfig --level 2345 mysql on
(this will make sure that mysql runs at level 2, 3, 4 and 5)
On my machine (Fedora 2) it runs at 2,3,4 and 5.
Once you have it run at a level you can verify it by looking at rcX.d (X being
a level):
for example to check that it runs at level 4:
go to /etc/rc.d/rc4.d/
and look at a file named ...mysql
S20mysql
(S means it will be picked up by the inetd daemon)
K30mysql
(K means Kill and mysql wont start)
good luck
Laurie
On Wednesday 30 March 2005 09:26 pm, Mark Sargent wrote:
Hi All,
below is my /etc/init.d/mysql content, but, mysql is not starting at
boot on Fedora3. Have I missed something fundamental.? I need mysql to
start at boot for snort to connect to it. Currently, snort gives an
error stating it can't connect. Cheers.
Mark Sargent.
[EMAIL PROTECTED] ~]# cat /etc/init.d/mysql
#!/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 20
# 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: 2 3 4 5
# Default-Stop: 0 1 6
# 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=
# 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
mode=$1# start or stop
case `echo testing\c`,`echo -n testing` in
*c*,-n*) echo_n= echo_c= ;;
*c*,*) echo_n=-n echo_c= ;;
*) echo_n= echo_c='\c' ;;
esac
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
#
# Test if someone changed datadir; In