I installed it it via mac ports, what's the command I have to stop the server (i have to test how my application behave when MySQL is dead)

You will find two cases based on whether you installed mysql using the official binary installer or using macports:


sudo launchctl unload -withCollectionOrLaunchDaemons/org.macports.mysql.plist

sudo launchctl load -withCollectionOrLaunchDaemons/org.macports.mysql.plist

Note: this really is persistent after reboot.

Binary installer

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

You could use command "mysqladmin shutdown"

sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop

You may also use start and restart here. I discovered this by searching in the items in /Library/LaunchDaemons/org.macports.mysql.plist.

Apparently you would like:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

Possess a further read here: http://world wide web.simplisticcomplexity.com/2007/10/27/start-and-stop-mysql-in-mac-os-x-105-leopard/

Well if everything else fails you can simply take the callous approach and get rid of the process running mysql by hand.

i.e. "ps -Af" to list out all processes, then do "kill <pid>" where <pid> is the procedure id from the mysql daemon (mysqld).


sudo <path to mysql>/support-files/mysql.server start
sudo <path to mysql>/support-files/mysql.server stop

else try :

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

however, I discovered the second item only labored (OS X 10.6, MySQL-5.1.50) when the .plist continues to be packed with:

sudo launchctl load -withCollectionOrLaunchDaemons/com.mysql.mysqld.plist

p.s I additionally discovered that I desired to not-load the .plist to obtain an not-related install of MAMP-mysql to begin / stop properly. After running running this MAMP-mysql begins all right:

sudo launchctl unload -withCollectionOrLaunchDaemons/com.mysql.mysqld.plist

For me personally it's using a "mysql5"

sudo launchctl unload -withCollectionOrLaunchDaemons/org.macports.mysql5.plist

sudo launchctl load -withCollectionOrLaunchDaemons/org.macports.mysql5.plist

Should you installed mysql5 package with macports:

sudo launchctl  unload -withCollectionOrLaunchDaemons/org.macports.mysql.plist


sudo launchctl  unload -withCollectionOrLaunchDaemons/org.macports.mysql5-devel.plist

should you installed mysql5-devel package.