0

I looked allover to a resolution to this but i'm just not finding it. I am trying to use drush on my MAMP platform (I have Leopard). Installation seems to have gone well, but i get errors when i try to use it.

My default shell is tcsh. I made a file .bash_profile and added the line "export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH" to it. then I changed to the bash shell and sent command: drush en views_ui. (I get the same error from the tcsh shell)

I am at the root of the site.

sorry if this is a repeat question. please help...


bash-3.2$ drush en views_ui
Command pm-enable needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to  [error]
run this command.
The drush command 'en views_ui' could not be executed.                                                                                [error]
Drush was not able to start (bootstrap) the Drupal database.                                                                          [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with
a working database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to: 
  Drupal version    : 7.0
  Site URI          : http://default
  Database driver   : mysql
  Database hostname : localhost
  Database username : root
  Database name     : d7dev
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /private/etc/php.ini
  Drush version     : 5.8
  Drush configuration: 
  Drupal root       : /Applications/mamp/htdocs/d7dev
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  File directory path: sites/default/files
  %paths            : Array
Siguza
  • 21,155
  • 6
  • 52
  • 89
user2216249
  • 1
  • 1
  • 2
  • just a quick question - is MAMP running when you execute commands? Seems like drush can't connect to db server. – Vadim Eremeev Mar 27 '13 at 16:46
  • yep, mamp is running (MAMP window is there...green light next to MySQL server is on... I can connect to my drupal site via localhost...) – user2216249 Mar 27 '13 at 16:58
  • Most likely your CLI user doesn't have read permissions over `sites/default/settings.php` – Clive Mar 27 '13 at 16:59
  • did sudo chmod +r+w+x sites/default/settings.php ... same problem ... or should i do something else? (thanks for your help) – user2216249 Mar 27 '13 at 17:04
  • got it! : did all this, as per http://brianfisher.name/content/drupal-development-environment-os-x-mamp-eclipse-xdebug-and-drush: sudo mv /usr/bin/php /usr/bin/php.default sudo ln -f /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php sudo chmod +x /usr/bin/php sudo ln -f /Applications/MAMP/Library/bin/mysql /usr/bin/mysql sudo chmod +x /usr/bin/mysql sudo ln -f /Applications/MAMP/Library/bin/mysqldump /usr/bin/mysqldump sudo chmod +x /usr/bin/mysqldump sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock – user2216249 Mar 27 '13 at 17:32
  • ..i figure it was a permissions issue related to mysql as mentioned... thank you all for your help – user2216249 Mar 27 '13 at 17:34
  • @VadimErmeev : I'm curious why you thought that drush couldnt connect to db though (probably true) – user2216249 Mar 27 '13 at 17:37
  • 1
    Shouldn't this be asked at http://drupal.stackexchange.com/? – madth3 May 10 '13 at 22:22

3 Answers3

3

So I know this is an old one, but did you try the solution at https://drupal.org/node/1428638 (the URL provided in your error message above)?

The upshot is that you should update your database 'host' value in settings.php with this:

'host' => php_sapi_name() == 'cli' ? '127.0.0.1' : 'localhost',

Worked great for me.

Jamie Taylor
  • 4,709
  • 5
  • 44
  • 66
1

I was running into the same issue on my local dev (not using XAMP or MAMP). All I did was install php5-mysql and drush en worked.

0

For the people like me with the same issue for XAMPP how ended up here on this article somehow. The follow line of code did te trick for me. Make sure you "cd" first to you're Drupal root.

sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql /var/mysql
ThomasA
  • 1,581
  • 1
  • 11
  • 9