Enables mysql to be automatically started when Mac is started, and mysql to be started when Mac is started
Before mysql was installed, the installer automatically added system services and started mysql when the system was started.
However, after upgrading Mac OSX to 10.10.1 Yosemite today, we found that mysql was not started when the system was started.
Try mac launchctl to implement this function.
The method is also simple.
1. edit a mysql Startup File.
Enter:
sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
2. Enter the Startup File Content:
<?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>--user=root</string> </array> </dict> </plist>
The/usr/local/mysql/in the xml above is the directory where my mysql is located.
3. Load the Startup File
Enter:
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
In this way, you will find that mysql is successfully started.
I have to say that the new Mac version is quite nice.