Shell script to start, stop, and restart MySQL

Mac OS X automatically executes all scripts under the

/Library/StartupItems

Directory when the system boots up. If that directory does not yet exist, you will need to create it.
For MySQL, you should create the directory

/Library/StartupItems/MySQL

and place the startup shell script MySQL and the configuration file StartupParameters.plist in that directory.
Once those files are set up, you need to edit the host configuration file

/etc/hostconfig

and add the line:

MYSQLSERVER=-YES-
1.2.3.1.1 MySQL
The shell script to start, stop, and restart MySQL looks like this:

"#!/bin/sh
. /etc/rc.common
StartService( )
{
if [ "${MYSQLSERVER:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting MySQL"
cd /usr/local/mysql
bin/mysqld_safe –user=mysql &
fi
}
StopService( )
{
ConsoleMessage "Stopping MySQL"
/usr/local/mysql/bin/mysqladmin shutdown
}
RestartService( )
{
if [ "${MYSQLSERVER:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Restarting MySQL"
StopService
StartService
else
StopService
fi
}"

StartupParameters.plist

The configuration file looks like this:
"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/
DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>Description</key>
<string>MySQL Database Server</string>
<key>Provides</key>
<array>
<string>MySQL</string>
</array>
<key>Requires</key>
<array>
<string>Network</string>
</array>
<key>OrderPreference</key>
<string>Late</string>
</dict
></plist>"

Once installed, you should run the mysql_install_db tool to set up your databases.

Under FreeBSD, for example,
place this script in
/usr/local/etc/rc.d.

Once installed, you should run the mysql_install_db tool to set up your databases.

Well after starting the server, and before doing anything else, set a password for the root user:

mysqladmin -u root password a_good_password
Companies Price Server Location Price Visit Now
adroitssd
Cloud SSD Hosting
$1.43 /mo. WILMINGTON, DE, US Price @ $1.43 /mo. Visit Now
247-host $2.99 /mo. LASALLE, CA Price @ $2.99 /mo. Visit Now
ehost.com $2.75/mo. Burlington, MA, US Price : $2.75/mo. Visit Now
siteground
Lifetime Free Domain
$3.95/mo. Panama, PA Start @ $3.95/mo. Visit Now
webhostingpad $1.99/mo. Arlington Heights, IL, US Start @ $1.99/mo. Visit Now
webhostingbuzz $4.95/mo AUBURN, MA, US Start @ $4.95/mo Visit Now
ipage
Cheapest Webhosting
$3.25/mo. Burlington, MA, US Start @ $3.25/mo. Visit Now
ixwebhosting $3.95/mo Columbus, OH, US Start @ $3.95/mo Visit Now
sitevalley $4.95/mo NASHUA, NH, US Start @ $4.95/mo Visit Now
liquidweb.com
Managed WordPress Hosting
$89.00/mo. Lansing, MI, US Price : $19.00/mo. Visit Now

Published by ananovareviews

I'm Communication Director with SCPL. Our goal is to deliver the most accurate information possible based on the needs of the majority of website owners and developers, and Ananova reports deliver the most reliable indicators of web host performance. - http://www.ananova.com

%d bloggers like this: