Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000]  No such file or directory’
I was getting this error when i tried to run magento script from command line on Mac OSX.
If you have the same problem like me, find out the location of your mysql.sock. You can do that as follows
mysql -u root -p show variables like '%socket%'
Now go to your local.xml and change your host to
Updated on Jan 5, 2014: This error is due to you installed XCode with its bundled PHP. Another solution is to add your own PHP executable into your environment variable $PATH, to do so, you can edit your ~/.bash_profile to add/replace with following line (while /usr/local/zend/bin should be replaced by where your php executable located):