Shell script to start, stop, and restart MySQL

Mac OS X automatically executes all scripts under the


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


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


and add the line:

The shell script to start, stop, and restart MySQL looks like this:

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


The configuration file looks like this:
"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/
<plist version="0.9">
<string>MySQL Database Server</string>

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

Under FreeBSD, for example,
place this script in

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
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 $2.75/mo. Burlington, MA, US Price : $2.75/mo. Visit Now
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
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
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. -

%d bloggers like this: