If enabling “Automatically Start MySQL Server on Startup” does not work then doing below process will fix it.
Open terminal/command line interface (CLI) and run below commands.
- run “sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist” and add below code and save the file. If vi does not work then create file “com.mysql.mysql.plist” in “/Library/LaunchDaemons/” and save below code.
<?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>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>
</array>
</dict>
</plist> - sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
- sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
- sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
Now restart the system and see that MySQL will be in running mode and no need to manually start.
I tried the above recipe but got the following result on the final command line:
Rowland@Mac-mini ~ % sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
Load failed: 5: Input/output error
Try running `launchctl bootstrap` as root for richer errors.
My environment: Mac Mini M1 running Mac OS 15.6.1
Any suggestions?
Can be due to the MAC OS version. Can you try below and see if it works?
1. Run “sudo vi /Library/LaunchDaemons/com.mysql.mysqld.plist” and add below content:
Label
com.mysql.mysqld
ProgramArguments
/usr/local/mysql/bin/mysqld_safe
RunAtLoad
KeepAlive
StandardErrorPath
/usr/local/mysql/data/mysqld.err
StandardOutPath
/usr/local/mysql/data/mysqld.out
2. Run:
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.mysql.mysqld.plist
If it’s already loaded, unload first: sudo launchctl bootout system /Library/LaunchDaemons/com.mysql.mysqld.plist
3. Verify with “sudo launchctl list | grep mysql” if com.mysql.mysqld listed.
may be try “sudo launchctl enable system/com.mysql.mysqld” to enable on boot explicitly
Thanks for your time in responding to my question. I tried the commands in your latest suggestion and had the following results:
Rowland@Mac-mini ~ % sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
Rowland@Mac-mini ~ % sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysqld.plist
Rowland@Mac-mini ~ % sudo launchctl bootstrap system /Library/LaunchDaemons/com.mysql.mysqld.plist
Bootstrap failed: 5: Input/output error
NB I am not using the vi editor as I find it too much like hard work! I use BBEdit which is much more people-friendly. Here is the content of the file com.mysql.mysqld.plist as entered and saved in BBEdit:
“Label
com.mysql.mysqld
ProgramArguments
/usr/local/mysql/bin/mysqld_safe
RunAtLoad
KeepAlive
StandardErrorPath
/usr/local/mysql/data/mysqld.err
StandardOutPath
/usr/local/mysql/data/mysqld.out”
I note that in your original post there were XML tags with declarations in the file com.mysql.mysql.plist – are these features optional?
Apologies if I am asking dumb questions!
in friendship
Rowland