PDOException: SQLSTATE[HY000] [2002] No such file or directory in _registry_check_code()
For simplicity check drush status with verbose and debug parameters:

drush -vd status


If you're using different profile, don't forget to include it as -l http://foo.

If you still have a problem, it's an issue with bootstrapping your Drupal.

First check your SQL connection if it's working:

drush sql-cli


If it does not, check your db credentials in your Drupal settings file.

If it does, there is a problem with SQL connection through the socket.

So in MAMP you've to do:


Check value of socket in my.cnf (menu: File/Edit Template), it's usually set as:

socket      = /Applications/MAMP/tmp/mysql/mysql.sock

Double check if your MySQL can find this file:

$ mysql_config --socket
/Applications/MAMP/tmp/mysql/mysql.sock

Double check if your PHP has the right mysql.sock set-up:

$ php -i | grep mysql.default_socket

Link the socket into your /tmp and see if that helps:

sudo ln -s /Applications/MAMP/tmp/mysql /var/mysql

Test the socket file:

mysql --socket=/var/mysql/mysql.sock

Still the problem? Add the following setting into your $databases:

$databases['default']['default'] = array(
  // ...
  'unix_socket' =&gt; '/var/mysql/mysql.sock',





Troubleshooting


Try: drush sqlq "SELECT @@version_comment LIMIT 1"
Try: drush ev "Database::getConnection('default', 'default');"
Try: mysql --socket=$(php -r 'echo ini_get("mysql.default_socket");')
Check permissions on Unix socket: stat $(mysql_config --socket)
Debug: on OS X with sudo dtruss -fn mysqld, on Linux with strace
Debug with XDebug:


echo '&lt;?php xdebug_start_trace("/tmp/foo.log");' &gt; init.php
drush -c init.php ev 'Database::getConnection("default", "default");'
or set xdebug.show_exception_trace=1 in your xdebug.ini

Check MySQL settings:


echo '&lt;?php phpinfo();' &gt; init.php
drush -c init.php  ev 'Database::getConnection("default", "default");' | grep mysql

Run: php -r "new PDO('mysql:host=localhost;port=3306;charset=utf8;dbname=dbname', 'root', 'root');"
Try to rebuilt your registry