how to kill process in Mac OS X and not have it restart on its own

The process you are killing is probably being managed by launchd, the proper way to stop it and have it not restart is to use launchctl unload <path to plist>. The plist that controls that process is in either /Library/LaunchDaemons or /System/Library/LaunchDaemons. If it is a system process and not one of your own, then you will probably have to use sudo to get launchctl to work as desired.

A better way try and stop it might be;

${MYSQL_HOME}/bin/mysqladmin -u root -proot shutdown > /dev/null 2>&1

A couple of comments mention that "launchd is probably involved" - so I thought I'd put this out as an additional answer. As @jarrod-roberson says, you can check if launchd is involved by first running launchctl list | grep mysqld.

An important thing you learn here is whether MySQL was installed with Homebrew or not - Brew stores its launchctl files in a different location than where OSX puts the "regular" services.

On my OSX box, the plist files are in ~/Library/LaunchAgents/ So I ran:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

to stop the MySQL server. I had previously looked in /Library/LaunchDaemons/ and /Library/LaunchAgents but didn't find a file with mysqld in its name.

You can also install a brew-based system called services, to manage all Brew-installed services applications, as described in this post - http://robots.thoughtbot.com/starting-and-stopping-background-services-with-homebrew I haven't tried this myself, though, so YMMV.


I tried to kill the process by sending it the TERM signal, and that worked. The command was:

sudo kill -15 {PID}