Ok, this thread was completely un-helpful. If you want the answer to the “error establishing database connection” problem on Mac OS X, here it is:
The problem is that using localhost has PHP try to connect using a socket at /var/mysql/mysql.sock (which is not where it is on OS X).
The easiest way to fix this is to use host 127.0.0.1
Hope that helps.