Skip directly to content

Using DAMP MySQL from the Command Line

Kelly Bell's picture
on Fri, 05/28/2010 - 8:12pm

I have had trouble for months trying to get MySQL to run in Snow Leopard. I've read multiple tutorials on the web about this issue, and while it's a well-known problem and there is quite a bit of documentation on the fix, in the end I never got any of them to work properly. I was forever getting an error saying that the system could not find the connection, or .sock file, for MySQL, but there were other problems as well. I finally decided it was kind of ok that it wasn't working, because what I really wanted was to be able to use the command line to run commands for the MySQL instance in my DAMP environment anyway. In case you're unfamiliar, DAMP = Drupal/LAMP - a nice local LAMP dev environment set up specifically for Drupal by the swell folks at Acquia -

The fact that the OS X version of MySQL could not find the mysql.sock file to start up MySQL, which was supposed to be located in /tmp/mysql.sock, gave me a clue. Even when I had managed to get the file in there properly, it still did not work. But since I knew my DAMP MySQL was working just fine, and since that was the one  I wanted to use anyway, I decided to try and fool OS X into using the DAMP version instead. As silly and no doubt obvious as this sounds, all I did was create a symlink (symbolic link) from the default mysql socket connection file to the .sock file that runs inside DAMP.

Mac OS X normally looks for the .sock file in /tmp/mysql.sock. The .sock file for DAMP resides in /Applications/acquia-drupal/mysql/data/mysql.sock. The solution is simply to open Terminal, and after logging in, type ln -s /Applications/acquia-drupal/mysql/data/mysql.sock /tmp/mysql.sock. Depending on the way your system is set up, you might have to use the sudo command first in order to create your symlink. For more info on sudo, making symlinks and other commands in OS X, please visit

This trick works equally well with MAMP, except you'll have to change the path to match MAMP's directory organization. For example, MySQL in DAMP is /Applications/acquia-drupal/mysql/bin/mysql, but in MAMP the same file is located in /Applications/MAMP/Library/mysql.

Speaking of Terminal, an old chestnut of a Terminal emulator for the Mac has gained a new lease on life, and the latest version is really quite good. I use it all the time now. It's called iTerm, and it's a vast improvement over OS X's native Terminal app. You can find iTerm at 

I'm quite sure that I'm doing this all wrong, for instance I'm sure I should be editing the location of the actual versions of MySQL which I want to use by entering them into my bash config file or something. But this trick solved my problem and has made my life a lot easier, and I thought perhaps someone else might benefit.

Happy coding,