I keep having to do this and I'm writing this here so that I remember how to fix it:
PHP is trying to connect through /tmp/mysql.sock by the /etc/my.cnf file is pointing to /var/mysql/mysql.sock.
So I just put a symlink in tmp to redirect the connection:
ln -s /var/mysql/mysql.sock /tmp/mysql.sock