I came across this problem when I converted to a Mac and I was trying to connect to a MySQL database on MAMP using CocoaMySQL. CocoaMySQL wasn’t able to connect to the database. Thought the solution may be useful to others.
Settings
Host:localhost
User:root
Password:root
If you try to connect now you may get the following error:
Unable to connect to host localhost.
Be sure that the address is correct and that you have the necessary privileges.
MySQL said: Access denied for user ‘root’@'localhost’ (using password: YES)

Solution
So here’s the extra bit. Enter the following in the socket field:
/applications/mamp/tmp/mysql/mysql.sock

Happy days!
October 24th, 2008
Phil Thompson says:
Ah, yes I remember this form when I first setup MAMP/CocoaMySQL. Actually, I tend to use MySQL Tools’ Administrator and/or Query browser for my MySQL needs and don’t use CocoaMySQL but perhaps I should give it another whirl.
November 9th, 2008
JesperA says:
Thanks for the tip, CocoaMySQL (now Sequel Pro) works great, one question though, is it possible to connect to a MySQL database that´s not on my computer?
November 9th, 2008
Lee says:
@JesperA: Yes you should be able to, as long as your host allows it
May 22nd, 2009
Julia says:
I have spent ages trying to figure this out. I put in my very specific google query with little hope of an answer and here it is! Thankyou thankyou thankyou!
June 17th, 2009
Paul says:
thanks a million! That was just the information I needed…
September 30th, 2009
JK says:
This post is a little lifesaver to those of us dabblers in the realm of MySQL (who don’t understand the gory details, nor want to). In Sequel Pro (CocoaMySQL’s replacement), this hint can be used to connect to MAMP MySQL, but isn’t required. In Sequel Pro, there are two ways to connect (actually, three, but SSH is over my head): Standard and Socket. In Standard, you can connect using host “127.0.0.1″ and port “8889″. In Socket, you can connect using host “localhost” and socket “/applications/mamp/tmp/mysql/mysql.sock”. Some of this info is also alluded to on the welcome page that opens when you start up MAMP. By the way, for any Rapidweaver users out there, you can use this hint for viewing MAMP MySQL data (via PHP scripts) live in Rapidweaver’s preview mode. The PHP script to make the MySQL connection just specifies the host as the path to the socket, instead of “localhost”, for example:
$con = mysql_connect(“:/applications/mamp/tmp/mysql/mysql.sock”,”root”,”root”);
Note the “:” at the start of the path.
October 12th, 2009
joey says:
hello guy, can you send me a example code how to connet to mysql with cocoaMSQL in iphone? i have problem with that. thanks a lot.