I just started to use Drush and I think I have some miss-configuration somewhere. I use MAMP (on mac) and s/Applications/MAMP/htdocs/subastas is the folder for the Drupal installation.

The error tells me the site has not a configured database, but that is not true since the site is running just fine.

When I try to run the pml command I get this error message:

Dooghouse-iMac:subastas doghouse$ drush pml

PDO::__construct(): [2002] No such file or directory (trying to [warning]
connect via unix:///var/mysql/mysql.sock) environment.inc:517
Command pm-list needs a higher bootstrap level to run - you will need [error]
invoke drush from a more functional Drupal environment to run this
command.
The drush command 'lml' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have a configured database.

Drush was attempting to connect to:
Drupal version : 7.9
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database username : drupal
Database name : subastas
Default theme : garland
Administration theme: garland
PHP configuration :
Drush version : 5.2
Drush configuration:
Drupal root : /Applications/MAMP/htdocs/subastas
Site path : sites/default
Modules path : sites/all/modules
Themes path : sites/all/themes
File directory path: sites/default/files
%paths : Array

You can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line or $options['uri'] in your drushrc.php file.

This is the error message shown when using drush si:

My-Name-iMac:drupal-7.14 myname$ drush si --db-url=mysql://root:drupal@localhost:8889/d14
You are about to CREATE the 'd14' database. Do you want to continue? (y/n): y
sh: mysql: command not found
Starting Drupal installation. This takes a few seconds … [ok]
WD php: Warning: PDO::__construct(): [2002] No such file or directory [warning]
(trying to connect via unix:///var/mysql/mysql.sock) in DatabaseConnection->__construct() (line 304 of /Applications/MAMP/htdocs/drupal-7.14/includes/database/database.inc).
WD php: Exception: In order for Drupal to work, and to continue with [error]
the installation process, you must resolve all issues reported below.
For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory. Is the database server running? Does the database exist, and have you entered the correct database name?Have you entered the correct username and password? Have you entered the correct database hostname? in install_run_task() (line 417 of /Applications/MAMP/htdocs/drupal-7.14/includes/install.core.inc). WD php: Warning: Cannot modify header information - headers already [warning] sent by (output started at /Users/myname/Documents/drush/drush/includes/output.inc:37) in drupal_send_headers() (line 1239 of /Applications/MAMP/htdocs/drupal-7.14/includes/bootstrap.inc). Exception:

In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.
  • Is the database server running?
  • Does the database exist, and have you entered the correct database name?
  • Have you entered the correct username and password?
  • Have you entered the correct database hostname?

in install_run_task() (line 417 of /Applications/MAMP/htdocs/drupal-7.14/includes/install.core.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]

  • Have you tried other commands that also require a database connection? This can help to determine if it's a command-specific issue, or a site-specific one. Also you might try using command line options like drush -r /foo -l foo.example.com to test whether it's being called correctly. – Chris Cohen May 24 '12 at 12:38
  • Just as a side-note, your site reports it's using Drupal 7.9 which has security vulnerabilities...might be a good idea to upgrade to the latest version. I doubt that the Drupal version is causing you error though – Clive May 24 '12 at 12:48
  • You are right, any command related to database connection give the same error. What can I do? The database is fine since the website is running without problem. I found this post that maybe can help stackoverflow.com/questions/1819592/… – chefnelone May 24 '12 at 12:51
  • in php.ini I have mysql.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock I think is correct. – chefnelone May 24 '12 at 13:45
  • 3

I fixed by running these lines in the terminal.

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
  • Post about this here: mostafaberg.com/2011/08/… – beth Jun 26 '12 at 18:33
  • This fixed my problem. I was experiencing the exact same error and after executing the a suggested commands the error went away. Thanks a lot! – user2022258 Apr 28 '13 at 19:25

Find path to your mysql.sock (e.g. run: mysql_config --socket), then add extra line (with unix_socket) to your settings.php file:

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

Where /var/mysql/mysql.sock is your full path to your mysql.sock file.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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