I installed MySQL via MacPorts. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?
Apparently you want:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
Have a further read in Jeez People, Stop Fretting Over Installing RMagic.
In my case, it kept on restarting as soon as I killed the process using PID. Also brew stop
command didn't work as I installed without using homebrew. Then I went to mac system preferences and we have MySQL installed there. Just open it and stop the MySQL server and you're done. Here in the screenshot, you can find MySQL in bottom of system preferences.
This worked for me on macOS 10.13.6 with 8.0.12 MySQL
/usr/local/mysql/support-files/mysql.server start
/usr/local/mysql/support-files/mysql.server restart
/usr/local/mysql/support-files/mysql.server stop
On OSX Snow Leopard
launchctl unload /System/Library/LaunchDaemons/org.mysql.mysqld.plist
mysql> show variables where variable_name like '%dir%';
| datadir | /opt/local/var/db/mysql5/ |
sudo /usr/local/mysql/support-files/mysql.server stop