Archives
Admin / Logout

Adam Merrifield

a picture of me
I am a web designer, theme designer, professional photographer and internet personality. I make many pretty things and I write a lot of content for the internet.

I am one of those guys that, because of the industry I am in, need to be connected at all times. At any given moment you'll find me posting on a forum, updating with twitter, Digging things worthy of attention, uploading pictures, or tagging cool sites.

here i am

seyDoggy Systems:
This is home base, the corporate headquarters, the hub, if you will, seyDoggy.com.

seyDesign news:
these are the RapidWeaver related posts that originally appear in the seyDesign.com blog

Uploads from seyDoggy:
these are the pictures that I upload to flickr

Merrifield Photography:
as a professional photographer I my camera ready at Merrifield-Photography.com.

delicious.com/seydoggy:
these are the websites I want to share or revisit later on. I just tag them on delicious.com.

what i am

I am the owner and operator of seyDoggy Systems, a small theme, code and design outfit based in Kitchener, Ontario, Canada. We primarily develop web based technologies but have begun to dabble in the desktop realm.

what i do

I code like a fool. I design like a fool. I am happiest when I can split my time between the two (though I tire of Photoshop faster then I do TextMate or Terminal), and somehow I have managed to etch out a living doing so.

Configuring TextMate SQL to play with MAMP

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: How it should look in the TextMate SQL server prefernces

That’s it! Now you can freely execute SQL queries from TextMate using your MAMP MySQL engine.

[tags]TextMate, MAMP, MySQL, SQL, PHP, Apache[/tags]

Comments (11) | Trackback

11 Responses to “Configuring TextMate SQL to play with MAMP”

  1. Mark Says:

    Just came up against this problem myself with my MAMP setup, great solution! Thanks

  2. David Says:

    I am having trouble with this. When I enter the second command “sudo chown _mysql /tmp/mysql.sock”. I get the error message “chown: _mysql: Invalid argument”

    Do you know why this is?

  3. admin Says:

    @David, that would lead me to believe that mysql isn’t present or enabled on your machine? Or you are not the admin… what do you get when you type whoami into the command line, i.e.: Mac-Pro:~ username$ whoami

  4. David Says:

    It just returns my name. It looks like this desktop:~ davidnestelle$ whoami davidnestelle

    I am a complete novice, in fact the reason I’m trying to do this is so I can learn SQL. So any help is greatly appreciated! Thanks.

  5. admin Says:

    @David, well it looks like you have the privileges you need. If your new though, you might want to start here first: http://danbenjamin.com/articles/2007/11/installing-mysql-on-mac-os-x and http://www.klauskomenda.com/archives/2008/10/07/installing-apache-mysql-and-php-on-leopard/

  6. John Says:

    David, if you choose to follow the link to danbejjamin.com you will encounter a step that will set a export path to the mysql server you just configured. While the path will suffice for that specific server you will wan to change the path to the mysql server bundled with MAMP.

    To run the MAMP mysql server change the path to: export PATH=”/Applications/MAMP/Library/bin:/usr/local/mysql/bin:$PATH”

    /usr/localmysqlbin is just a default incase /Applications/MAMP/Library/bin is missing

    now text mate will know how to find your MAMP mysql server and you can activate your query browser in text mate with control + shift + q

  7. SohDubom Says:

    Hi. Interesting post you have. I was looking to something similar but with regards to the TM cmd+shift+R, when I want to run a PHP script with the TM internal browser. I was wondering if we could config TM to use the MAMP installed PHP instead of the MacOS PHP installation?

  8. seyDoggy Says:

    @SohDubom you probably could, but both Safari and FireFox will refresh as well if they are open, ultimately making the internal TM browser redundant. Since the TM browser is a bit underpowered I would go with the proper browsers.

  9. larsb Says:

    worked like a charm. thanks a bunch.

  10. Marc Says:

    Nice post but the image for the TextMate SQL bundle preferences is missing so we can’t see which SQL connection parameters to use! I’m using MAMP and phpMyAdmin works fine but TextMate won’t connect. I tried these values in the SQL bundle preferences and it just gives an error “Lost connection to MySQL server during query”.

    Title: mydb Server: MySQL Username: root Hostname: localhost Port: 8889 Database: mydb

    I tried ports 8888, 8889 as well as leaving it blank. “ps -awx” shows that “mysqld_safe” was started on port 8889.

    Any ideas?

  11. admin Says:

    My apologies, but some of these older posts have been moved from blog to blog to blog. I think this is more or less what the original image showed.

Powered by RapidWeaver, WP-Blog and WordPress 3.3.2