Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autostart MySQL Server on Mac OS X Yosemite/El Capitan

I would like to auto start the MySQL server on startup. This was possible in Mavericks but seems to be not working on Yosemite.

edit: seems this works with El Capitan as well

enter image description here

like image 915
Xaver Avatar asked Oct 20 '14 08:10

Xaver


People also ask

Why is MySQL not opening on Mac?

The reason behind the MySQL Workbench client not working can be many. It can be because your macOS version is not compatible with the version of the Workbench that you downloaded, or maybe because the version of Python installed on your macOS is not compatible with the version of Workbench you have downloaded.

Is MySQL installed by default on Mac?

By default, the MySQL directories are installed under /usr/local/ . Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell.


Video Answer


2 Answers

@dcc was very close. This is how MySQL autostarts again on Yosemite:

The com.mysql.mysql.plist in /Library/LaunchDaemons:

<?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=mysql</string>     </array>   </dict> </plist> 

Additionally I've changed the permissions based on this answer

sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist 

Finally I run this command

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist 

If you have any addition please share below!

like image 179
Xaver Avatar answered Oct 13 '22 06:10

Xaver


I followed @Xavers directions and upon trying to execute the command

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist 

was given the error:

/Library/LaunchDaemons/com.mysql.mysql.plist: Invalid property list

After scratching my head for a minute I found that removing the DOCTYPE DTD declaration at the top made the error go away and upon restart mySQL server is, indeed, running.

So, my XML looks like this:

<?xml version="1.0" encoding="UTF-8"?> <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=mysql</string>     </array>   </dict> </plist> 
like image 40
Yevgeny Simkin Avatar answered Oct 13 '22 05:10

Yevgeny Simkin