How to run a sudo command on mac? .. problem with mysql server
On OS X Yosemite you should add the script in:

/Library/LaunchDaemons


using this name for the script:

com.mysql.mysql.plist


and this content:

&lt;!--?xml version="1.0" encoding="UTF-8"?--&gt;
&lt;plist version="1.0"&gt;
  &lt;dict&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;dict&gt;
       &lt;key&gt;SuccessfulExit&lt;/key&gt;
       &lt;false/&gt;
    &lt;/dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.mysql.mysqld&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/usr/local/mysql/bin/mysqld_safe&lt;/string&gt;
      &lt;string&gt;--user=mysql&lt;/string&gt;
    &lt;/array&gt;
  &lt;/dict&gt;
&lt;/plist&gt;


you will get MySQL started automatically every time you reboot the Mac.

be sure to set proper privileges to the script:

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


Just tested on OS X 10.10.2 while moving out of MAMP PRO and it works like a breeze :-)