If you used an RPM or Debian package to install MySQL, this script is generally
already installed as /etc/init.d/mysql or
/etc/init.d/mysqld (MySQL daemon. Check what this script is called on your system using the ls command
ls /etc/init.d/mysql*/etc/init.d/mysql
In the preceding example,
the file is called mysql. Use the appropriate name (
mysql or mysqld
) where you see
mysqlin the commands below.
If you installed
from a tarball or from source, you’ll need to copy the file across yourself as discussed in the earlier section, Configuring a system-wide server installed from tarball or source.”
A Linux system can start in one of six
runlevels; a system starting in runlevel 5 will typically boot straight into the graphical windowing
environment such as KDE orGNOME, while a system starting in runlevels 2 or 3 will end up at a text-based login screen. There’s an easy way to check what runlevel you’re in just use the runlevel program in the
/sbin directory
/sbin/runlevelN Here, the system is in runlevel A program is started automatically fora particular runlevel if there’s a startup entry for it in the corresponding
/etc/rc.d directory. You
can list all the entries forMySQL by typing
ls /etc/rc*.d/*mysql*/etc/rc0.d/K90mysql /etc/rc2.d/S11mysql /etc/rc4.d/S11mysql /etc/rc6.d/K90mysql
/etc/rc1.d/K90mysql /etc/rc3.d/S11mysql /etc/rc5.d/S11mysql
The entries starting with S start the program when the system is booted, and the entries starting with K stop (or kill) the program when the system is shutdown. Here,
MySQL is set to start and stop automatically in runlevels 2, 3, 4, and 5.
On Red Hat orMandriva systems, you can more conveniently determine this using the chkconfig
--list command
chkconfig -list mysqlmysql off off on on on on 6:off
If your server shows off for the runlevel that you found using the runlevel command,
the MySQL server is not started automatically.
If you don’t see an entry for your preferred runlevel (normally 3 or 5), you’ll need to add one yourself. Most Linux distributions have a graphical tool to configure startup services. For example,
under Red Hat and Fedora, you can run the Service Configuration program by choosing the Services entry from the Administration submenu of the
System menu you can also run this program by typing
Share with your friends: