Difference between brew services start mysql` and `mysql.server start`
I installed MySQL using homebrew brew install mysql
and I noticed that MySQL can be managed in two different ways:
brew services start mysql
and mysql.server start
Is there any difference when starting the service with brew services as well as starting with the normal mysql.server method? Or are they basically the same thing, just a different alias?
They both seem to be using the same executable: /usr/local/Cellar/mysql/5.7.17/bin/mysqld
Thanks for the help!
source to share
According to the help message brew services
, on startup
brew services start mysql
it installs and runs the service formula on login (or loads if you run the command with sudo
). This means that you will now have a plist file in ~/Library/LaunchAgents
(or in /Library/LaunchDaemons
if you run the command with sudo
). For mysql, the plist file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=/usr/local/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>
</dict>
</plist>
this means that by default it mysqld_safe
is called with the command line parameters --bind-address=127.0.0.1
and --datadir=/usr/local/var/mysql
.
at startup
mysql.server start
you are executing directly the mysql script located at /usr/local/bin/mysql.server
The main difference is that with the version brew services
you run mysqld_safe
, which according to its man page:
adds some safety features such as restarting the server when an error
occurs and logging runtime information to an error log file.
source to share