Warm tip: This article is reproduced from stackoverflow.com, please click
apache macos mysql shell terminal

macOS shell script to stop and run apache and mysql

发布于 2020-04-07 10:19:49

I've asked already this but someone decided that the question had already an answer without understood really what I need. The old question is here I want to make a script that I can run from the terminal of osx to start apache and mysql using the start command and then when I finished with them, I want to use the stop command or something similar to stop and quit from them. I don't have experience with shell scripting, will be this possible? can someone help me?

Questioner
sisaln
Viewed
57
Bill Karwin 2020-02-01 01:55

MySQL is installed on MacOS as a launch daemon.

Here's the shell command to start and stop it:

sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

See https://dev.mysql.com/doc/mysql-osx-excerpt/8.0/en/osx-installation-launchd.html for more on the MySQL Launch Daemon.

An alternative way to install MySQL on MacOS is with brew. Then the usage to start and stop it is done with supervisord. Here's the way to start and stop a service managed by supervisord:

supervisorctl start mysql

supervisorctl stop mysql