#! /Bin/sh
# Start/stop/restart mysqld.
#
# Copyright 2003 Patrick J. volkerding, Concord, CA
# Copyright 2003 slackware Linux, inc., Concord, CA
# Copyright 2008 Patrick J. volkerding, sebeka, Mn
#
# This program comes with no warranty, to the extent permitted by law.
# You may redistribute copies of this program under the terms of
# GNU General Public License.
# To start MySQL automatically at boot, be sure this script is executable:
# Chmod 755/etc/rc. d/rc. mysqld
# Before you can run MySQL, you must have a database. to install an initial
# Database, do this as root:
#
# Mysql_install_db-user = MySQL
#
# Note that the MySQL user must exist in/etc/passwd, And the created files
# Will be owned by this dedicated user. This is important, or else MySQL
# (Which runs as user "MySQL") will not be able to write to the database
# Later (this can be fixed with 'chown-r mysql. MySQL/var/lib/mysql ').
#
# To increase system security, consider using "mysql_secure_installation"
# As well. For more information on this tool, please read:
# Man mysql_secure_installation
# To allow outside connections to the database comment out the next line.
# If you don't need incoming network connections, then leave the line
# Uncommented to improve system security.
# Skip = "-Skip-Networking"
Bin_path =/usr/local/mysql5077/bin
# Start mysqld:
Mysqld_start (){
If [-x $ bin_path/mysqld_safe]; then
# If there is an old PID file (No mysqld running), clean it up:
If [-r/var/run/MySQL. pid]; then
If! PS axc | grep mysqld 1>/dev/null 2>/dev/NULL; then
Echo "Cleaning up old/var/run/MySQL. PID ."
Rm-F/var/run/MySQL. PID
Fi
Fi
$ Bin_path/mysqld_safe-datadir =/data/DB-PID-file =/var/run/MySQL. PID $ skip &
Fi
}
# Stop mysqld:
Mysqld_stop (){
# If there is no PID file, ignore this request...
If [-r/var/run/MySQL. pid]; then
Killall mysqld
# Wait at least one minute for it to exit, as we don't know how big the DB is...
For second in 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 4 5 6 7 8 9 \
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 4 5 6 7 8 9 60; do
If [! -R/var/run/MySQL. pid]; then
Break;
Fi
Sleep 1
Done
If ["$ second" = "60"]; then
Echo "Warning: gave up waiting for mysqld to exit !"
Sleep 15
Fi
Fi
}
# Restart mysqld:
Mysqld_restart (){
Mysqld_stop
Mysqld_start
}
Case "$1" in
'Start ')
Mysqld_start
;;
'Stop ')
Mysqld_stop
;;
'Restart ')
Mysqld_restart
;;
*)
Echo "usage $0 START | stop | restart"
Esac