how to start a mysql server on login
The best way to do this is to create a launchd .plist, copy it to ~/Library/LaunchAgents and let the system handle it for you.

Sample .plist:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.user.startMySQL&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
          &lt;string&gt;mysql.server&lt;/string&gt;
          &lt;string&gt;start&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


I prefer to use the file naming convention com.user.&lt;name of function&gt;.plist when naming them so I can easily identify what is loaded and what is not.

Next, you need to load this .plist as root so it runs as root

$ sudo launchctl load com.user.startMySQL.plist

To verify that it has loaded you can issue the command sudo launchctl list and the command mysql to initiate a connection to the MySQL service.

Please note that this is just a simple example - you may wish to create a script to check to see if mysqld is already running before launching it.