MySQL is not installed on OS X Maverick 10.9 by default and needs to be downloaded from the MySQL site. When downloading you don’t have to sign up, look for the No thanks, Just take me to the downloads!. Once downloaded, install the 3 complonents. You may need to adjust the Security and Privacy System Pref to allow installing of 3rd party apps because of the new security feature in Mountain Lion. To get around this without changing the global preferences (best) right click or command click the .pkg installer to bring up the contextual menu and select open, then you will get a warning, click Open.
Install all 3 …
The first install is the MySQL software, the 2nd item allows MySQL to start when the Mac is booted, and the third is a Systems Preference that allows start/stop operation and setting of preferences.
You can start MySQL server from the System Preferences or via the command line.
To start MySQL from the command line use:
sudo /usr/local/mysql/support-files/mysql.server start
To find out the MySQL version:
/usr/local/mysql/bin/mysql -v (type \q to exit)
After installation, in order to use mysql commands without typing the full path you need to add the mysql directory to your shell path. This is optional but does save some typing. This is done by appending the mysql directory onto shell path in the .bash_profile. The following command will put the path at the end of the .bash_profile file.
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
Set the MySQL root password
This password is not the same as the admin password for OS X, this is a unique password for the mysql root user. Use one and remember it.
/usr/local/mysql/bin/mysqladmin -u root password 'yourpassword'
User the single ‘quotes’ surrounding your password.
Fix the 2002 MySQL Socket error
MySQL and OS X do not agree on where the MySQL socket should be placed. MySQL wants to see it in /tmp and OS X looks for it in /var/mysql. To fix this error, just create a sym link to the correct location.
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock