If you’ve recently installed or upgraded to Coda 2, are using MAMP to manage your development stack, and are looking to use the built-in MySQL frontend, here’s what you need to do in order to connect to MySQL in Coda 2.

Coda 2 and MAMP MySQL Socket

Setting up a connection between your project and its database is easy. It really only takes a single step though it assumes you know the username and password to your local database (which I can’t imagine why you wouldn’t know it :).

MySQL in Coda 2

First, select ‘MySQL Socket’ from the Connect To area then paste the following line into the ‘Socket’ field:

/Applications/MAMP/tmp/mysql/mysql.sock

This will then allow Coda to connect to the databases you’ve likely been managing with another client such as phpMyAdmin.

In the comments, Gavin asked how to store the settings for a given site or application. To do this:

  • Go to the Coda 2 home screen where it lists all of your projects.
  • Two-finger click on the site and click on ‘Edit’
  • Click on the ‘Database’ tab and enter the socket information

Coda 2 Edit Site

This will store the settings so you won’t have to enter it each time for each site.

Category:
Tips

Join the conversation! 30 Comments

  1. Thanks for that Tom! I was wondering how to set that up for use with MAMP. You just increased my productivity!

  2. How are these connections saved in Coda? I keep having to re-type the MySQL credentials into a new “Add – Connect to MySQL Server”.

  3. I’m new to SQL and this tip helped me a lot, so thanks! How do I ‘publish’ the db I created in Coda 2 to my remote db?

    • To my knowledge, Coda 2 doesn’t actually support this functionality, but you could do an export and then import that into your remote environment.

      The tricky part about that is making sure all of your URL’s are still properly defined in the database; otherwise, you’ll have problems :).

  4. now this is for local site, what if it is remote site??

    thanks

  5. Hi Tom, I followed your instructions but all I get is this error:

    Unable to connect to host /Applications/MAMP/tmp/mysql/mysql.sock, or the request timed out.

    Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 0 seconds).

    MySQL said: Can’t connect to MySQL server on ‘/Applications/MAMP/tmp/mysql/mysql.sock’ (60)

    —-

    Any ideas what I have done wrong?

  6. What about not be able to connect to an external server (Host: GoDaddy)?

  7. Thanks! This was a huge help!

  8. I need to connect to my on server database . How do I achieve that ?

  9. Yes! Finally someone writes about download.

  10. Thanks for this! It’s a gift that’s still giving. I just downloaded and installed the Coda 2 eval today, and it feels good, but help with the learning curve is always — well, helpful!

  11. Thanks so much! Exactly what I was looking for :)

  12. Thank you! It worked!

  13. For those novices who still can’t get it working (i.e. read: myself…), you have to find where the file “mysql.sock” is and enter that location into field “Socket:”. In my case the file was simply in the /tmp folder. I have no idea how it got there or what this location implies, but right now the most important thing is that I got the connection! Thanks Tom, this was a good starting point!

  14. Is it possible to export db as .sql file with Coda? Good stuff, thanks.

  15. I just switched over from MAMP to the local install in Yosemite. Any idea on how to connect via the Coda MySQL tab with this? Thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.