Brew services has installed this plist file for mysql.
~ $ brew services list Name Status User Plist mysql56 started mh /Users/mh/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
Is this file safe to edit (i.e. will brew ever overwrite changes made here)? Is there another method I should use to modify the file?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
All .plist
files that come with Formulas can be found in Cellar dir. For instance homebrew.mxcl.mysql.plist
is in /usr/local/Cellar/mysql/5.7.14
. You can modify it and brew services
will use it.
Alternatively you can modify /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
and make it immutable with sudo chflags uchg /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
. This won’t allow brew
to rewrite or modify .plist
file.
Method 2
- Copy
/Users/mh/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
somewhere - make changes to copy of plist
- run
brew services start mysql56 {path to modified copy of plist file}
Update 2022 – for newer versions:
- run
brew services start mysql56 --file=path to modified copy of plist file
Method 3
I (unfortunately) don’t know which file you can edit, but I can confirm that editing anything in the Library/LaunchAgents
directory will be overwritten by brew services
on the next start, so editing it directly isn’t going to help.
Method 4
Short answer:
Edit the configuration in usr/local/Cellar/
+ name of the Formula / + .plist
file
NOT in the file listed next to the daemon in brew services
listing
Long answer:
When you install a Formula, its plist
file lands in usr/local/Cellar
, in a dir named after the formula.
When you spawn a daemon with brew services start
, this file is then copied to the running user’s Library/LaunchAgents/
, e.g.:
for root, it’s Library/LaunchAgents/
for a normal user – ~/Library/LaunchAgents
This is important, there is no point in changing this file, it’s just a copy that will be overwritten next time you run the service as this user.
However, you can examine this file to see what configuration was used for this particular instance of the service.
Method 5
When you install a package with Homebrew formula
a .plist file is placed in the package folder
(usually /usr/local/Cellar/… folder)
in OSX this file is copyed/deleted to/from the
/Library/LaunchDaemons/
folder
every time tou start/stop the service with Homebrew:
brew services start <the-app> brew services stop <the-app>
Better then ‘blocking’ this file
is acting over the file in your package folder…
this example is for OSX/Mojave & MariaDB:
suppose you want to change the default data folder
and the TCP port from 3306 to 3308
edit the
/usr/local/Cellar/mariadb/10.4.6_1/homebrew.mxcl.mariadb.plist
locate this section in the XML
make you desired changes (choose you desired folder):
... <string>/usr/local/opt/mariadb/bin/mysqld_safe</string> <string>--datadir=/DAT/mariadb</string> <string>--port=3308</string> ...
then just stop and restart the service with Homebrew
et voilá… you can use netsat to confirm:
netstat|grep 3308
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0