upgraded mamp to mamp 2.0 and now drush cant find the database

> drush st
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [warning]
drush_valid_db_credentials() (line 1234 of /Users/mortendk/drush/includes/environment.inc).
Drupal version : 7.4
Site URI : http://drupal7.local
Database driver : mysql
Database hostname : localhost
Database username : root
Database name : drupal7
Default theme : garland
Administration theme : garland
PHP configuration :
Drush version : 4.4
Drush configuration :
Drush alias files :
Drupal root : /Users/mortendk/Dropbox/websites/drupal7
Site path : sites/drupal7.local
File directory path : sites/drupal7.local/files

beeing a total noob with this area of webdevelopment, can someone point me in the right direction ?
i tried:
> drush fix this problem for me
command but it didnt work ;)

cheers

Comments

mortendk’s picture

Title: mamp 2.0 = no database connection » mamp 2.0 drush cant fint mysql.sock
mortendk’s picture

After digging down into drush i found out that its not looking the right places for the php stuff

mamp changed the directories so to fix this asap i added
/Applications/MAMP/bin/php/php5.2.17/bin/php
/Applications/MAMP/bin/php/php5.3.6/bin/php
to drush/drush

#  for amp_php in /Applications/MAMP/bin/php5/bin/php /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5.3/bin/php /opt/lampp/bin/php /Applications/xampp/xamppfiles/bin/php /Applications/acquia-drupal/php/bin/php; do
#  for amp_php in /Applications/MAMP/bin/php5/bin/php /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5.3/bin/php /opt/lampp/bin/php /Applications/xampp/xamppfiles/bin/php /Applications/acquia-drupal/php/bin/php /Applications/MAMP/bin/php/php5.2.17/bin/php /Applications/MAMP/bin/php/php5.3.6/binphp; do

Im pretty sure this is a temporary solution, but this at least got it to work

FFFFFFFab’s picture

Thanks, I had the same issue and your solution fixed it.

greg.1.anderson’s picture

Status: Active » Fixed

Note that in drush-5, the special handling of *AMP as shown above was removed. See the README.text in drush-5 for configuring drush on *AMP for the latest version of drush.

cdracars’s picture

#2 fixed issue. Question is drush-5 "ready" for use?

hs@henrikstrindberg.se’s picture

Thanks, # 2 fixed it for me too but with one more slash added near the end:
/Applications/MAMP/bin/php/php5.3.6/binphp; do
should be:
/Applications/MAMP/bin/php/php5.3.6/bin/php; do

mducharme’s picture

Thanks for this!

fragje’s picture

Thanks! #2 and #6 (small spelling correction) fixed it for me. I guess this is the price of a early upgrade to Lion and MAMP 2.0

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pierrelord’s picture

Big thanks for this.

squiggy’s picture

Thank you!!! #2 and #6 fixed this for me.

Melissamcewen’s picture

#2 and #6 worked for me! Thanks!

August1914’s picture

I also needed #2 and #6 to get Drush 4.5 working under my MAMP 2.0 installation, but I also needed to tell drush where to look for mysql, (specifically, mysql.sock); there are various ways to do this; I accomplished this by creating a sym link, per:
https://drupal.org/node/251837#comment-906520

Thanks, all.

modulist’s picture

Thanks for the #14 tip on the symlink to mysql.sock... It worked for me with drush 4.5 and MAMP 2.0.

Prine’s picture

I got around this by setting an environment variable (as specified by README.txt)

- If you want to run drush with a specific version of php, rather than the
one found by the drush command, you can define an environment variable
DRUSH_PHP that points to the php to execute:
export DRUSH_PHP=/usr/bin/php5

I opened my .bash_profile

sudo nano ~/.bash_profile

Then entered

export DRUSH_PHP=/Applications/MAMP/bin/php/php5.2.17/bin/php

Saved, closed terminal then launched terminal (important!) to load new changes.

NOTE: You can specify which flavour of php you wish to use by changing the path to desired php version. Above points to 5.2. MAMP comes packed with both 5.2 and 5.3

betz’s picture

Comment #15 did the trick, and is a cleaner solution then patching drush.
Thanks Morten and Prine

batigolix’s picture

creating a symlink as explained in the drush README.txt does the trick for MAMP 2 & Drush 5:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

suntog’s picture

Thanks for this post! This was driving me crazy. I followed the drush README.txt and reset my path in .bash_profile with this line of code:
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH"

Then I had to take the extra steps as outlined in the README.txt:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Mark_L6n’s picture

I just upgraded MAMP , which currently has PHP 5.3.6, and got the error. Using drush 4.5.
Using this command fixed everything for me:
export DRUSH_PHP=/Applications/MAMP/bin/php/php5.3.6/bin/php

ksoldink’s picture

#15 did the trick for me! Thanks!

R.Hendel’s picture

Thanks a lot for #17 :-)

drupalninja99’s picture

#18 works for me

Jeff Burnz’s picture

suntog re #18, you rock, thanks a lot!

Anonymous’s picture

suntog #18. That worked perfectly. Thanks!

david.mccandless’s picture

#15 worked for me as well. FYI, you can avoid closing and re-launching terminal by executing the following command after modifying your .bash_profile:

source ~/.bash_profile

jenlampton’s picture

edit: #15 does not work for drush 8.x-6.x-dev :/

greg.1.anderson’s picture

DRUSH_PHP still working for me on the latest 8.x-6.x-dev. Shell must be bash for #15 to work; other environments might have slightly different syntax for exporting environment variables.

As an alternative, you could always try:

alias drush='/usr/bin/env DRUSH_PHP=/path/to/php drush'

Verify path to env with which env.

greg.1.anderson’s picture

If you are just looking for a solution to the can't find mysql.sock problem, there could be some other cause than using the wrong php. See the accepted answer here:

http://drupal.stackexchange.com/questions/80350/unable-to-display-drush-...

johnatasJMO’s picture

This worked for me:
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

As shown on: http://drupal.stackexchange.com/questions/32111/get-an-error-if-i-run-th...