Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

NRose8989

macrumors 6502a
Original poster
Feb 6, 2008
629
0
I manually installed mySQL 5.1 so I can't use the pref pane that I would normally get when installing mySQL as a installer package. So I would like to make two scripts (".start" and ".stop") that will live in my home folder, so I can quickly start and stop them when open terminal. I kinda have an idea on how to make it but I don't know how to have the script enter my admin password when it is prompted (or if thats even possible).

the two commands to start and stop it are as follows:

to start:
Code:
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

to stop:
Code:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

Thanks in advance.

EDIT: Nevermind I think I figured it out, Just had to change some permissions.

EDIT #2: So they work just fine but now I have that natural feeling to make it better. I currently have two scripts, one for starting, and one for stopping. How would I go about rolling them into one single script called ".mysql" and it will test if the mySQL server is already running (or not running) then execute the needed command. Do any of you know what is returned if one of these commands failed to execute?

I would think that I could use
Code:
test
and a series of if statements, assuming if the commands returned a integer.

any ideas?
 
Why can't you use the pref pane to start / stop MySQL ?

All it does will be to call mysqld_safe ? wherever that happens to be in your PATH.
 
Ya the pref panes doesn't work because I followed this tutorial and it doesn't work, not sure why but it doesn't.

I did it this way because the mySQL install packages didn't work when using ruby on rails.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.