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.


PDOException: SQLSTATE[HY000] [2002] No such file or directory in drupal_is_denied() (line 1917 of /Volumes/Doxy/htdocs/omegadoen/includes/bootstrap.inc).


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?


1 Answer 1


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:

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

    socket      = /Applications/MAMP/tmp/mysql/mysql.sock
  2. Double check if your MySQL can find this file:

    $ mysql_config --socket
  3. Double check if your PHP has the right mysql.sock set-up:

    $ php -i | grep mysql.default_socket
  4. Link the socket into your /tmp and see if that helps:

    sudo ln -s /Applications/MAMP/tmp/mysql /var/mysql
  5. Test the socket file:

    mysql --socket=/var/mysql/mysql.sock
  6. Still the problem? Add the following setting into your $databases:

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


  • 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 '<?php xdebug_start_trace("/tmp/foo.log");' > 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 '<?php phpinfo();' > 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
  • 3
    wow. this is a very complete answer. Surprised there are not more upvotes on this. Thanks. Commented Aug 17, 2016 at 3:19
  • 1
    I'd upvote this answer on all of the other "drush" "mamp" "mysql" related questions here on stack exchange, just so its easier to find... many of the other ones have really incomplete answers. Commented Aug 17, 2016 at 16:31
  • So I don't have this file /Applications/MAMP/tmp/mysql/mysql.sock nor this file /var/mysql/mysql.sock using MAMP. I can connect to phpMyAdmin no problem though..weird. Whenever I try drush cr I get the sql connection issue. I can drush sql-sync just fine though...
    – Ronnie
    Commented Oct 20, 2016 at 19:11
  • 1
    Absolutely brilliant answer. This is a very complete answer on a topic that is really obfuscated partly because of different set ups people are using and also a lack of understanding of how mysql works under the hood (at least on my behalf). Commented Dec 8, 2016 at 18:22
  • 1
    coming back nearly 3 years later with a new machine and this again solved my problem. I was wrong in my original comment from 2016. tmp is a hidden folder -_- I wish I could upvote again
    – Ronnie
    Commented May 22, 2019 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.