I was trying to generate model code from cake command line tool. But got this issue.
Warning Error: PDO::__construct(): [2002] No such file or directory (try
In my case the problem appear just after a power outage. So I fixed it by deleting the /Applications/MAMP/tmp/mysql/mysql.pid file and restarting MAMP.