PDOException: SQLSTATE[HY000] [2002] No such file or directory in _registry_check_code() Drush is running on MAMP, PHP 5.6.6. 

Inside /Volumes/Doxy/htdocs/omegadoen/sites/all/themes/omega 

I run: 

drush omega-wizard


I get:


  Additional uncaught exception thrown while handling
  exception. Original PDOException: SQLSTATE[HY000]
  [2002] No such file or directory in drupal_is_denied() (line 1917 of
  /Volumes/Doxy/htdocs/omegadoen/includes/bootstrap.inc).Additional
  PDOException: SQLSTATE[HY000] [2002] No such file or directory in
  _registry_check_code() (line 3169 of /Volumes/Doxy/htdocs/omegadoen/includes/bootstrap.inc).Drush
  command terminated abnormally due to an unrecoverable error.   [error]


What now?
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