Search code examples
mysqlmacosshellterminalosx-snow-leopard

Apache MySQL on OS X control script


So I configured apache and mysql on my OS X Snow Leopard, everything works fine so far. What I want to do now is create a script that allows me to start/stop the services in a glimpse.

Stopping the daemon works fine with

mysqladmin -u root -p shutdown

The problem is controlling mysql starting. To start the daemon directly on the terminal, I use

> mysqld_safe
[CTRL-Z]
> bg

But: How can I simulate this in a script file?


Solution

  • What about just send the process to the background?

    mysql_safe &
    

    You could also create a log file during the startup:

    mysql_safe --log-error=/tmp/mysqld.log &
    

    Also you want more validations, checking the status of the servers etc. You can take a look at how we do it in the BitNami MAMPStack. The script for MySQL it is placed in /mysql/scripts/ctl.sh