I want to preface this by saying that I might be totally ass backwards in doing this but I had a need and I answered it. So before you try what I am about to tell you, be warned, if this totally obliterates your computer, project, or anything at all… it’s not my fault!
Ok, here is my needs, part 1; I run MAMP on my system to develop web projects locally. I use MAMP because it has more up to date versions of Apache, PHP and MySQL and I can update any of those on the fly at any time. It’s great that OS X has all of this pre installed (save for the MySQL), but it just isn’t very fast and I’ve always felt that by banging on the these system services I can potentially harm my system as a whole. With MAMP, I can bang on the innards of it’s services all I want and only worry about breaking that which resides in the MAMP folder.
My needs, part 2; I am a heavy, heavy TextMate user and as it happens, TextMate is a brilliant SQL editor which allows for complex queries to be written in a comfortable editor (as opposed to the very linear Terminal.app) and executed in a sexy little browser. The problem with is that TextMate presumes you will compile your MySQL server in the standard location and configuration (/usr/local/mysql/), where as MAMP puts it all in it’s own folder located in the Applications folder (/Applications/MAMP/tmp/mysql/).
What I have found is that TextMate want’s to access the socket (mysql.sock) in the /tmp/ folder (buried in the /private/ folder on the hard drive), but I know the MAMP socket is located at /Applications/MAMP/tmp/mysql/. So I thought I would try making an alias of this socket in the /tmp/ folder for TextMate to find. And it worked.
WARNING: IF THE TERMINAL SCARES YOU THEN LOOK NO FURTHER
First, open terminal, then type in the following line to create the link (this is based on the assumption that you already have a /tmp/ folder which you should):
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
Next, you want to change the owner:
sudo chown _mysql /tmp/mysql.sock
And lastly the permissions:
sudo chmod 777 /tmp/mysql.sock
Now from the SQL bundle preferences in TextMate, add your server and database info (assuming you have already created a database). Remember that by default, MAMP MySQL administration is set to user: root, password: root (yikes, you might want to change that). It would look something like this:

That’s it! Now you can freely execute SQL queries from TextMate using your MAMP MySQL engine.
Technorati Tags: TextMate, MAMP, MySQL, SQL, PHP, Apache