I have a problem running some drush methods involving database connection. I run the free version of MAMP.

If I run methods like si or pml I get no problems

But if I run the drush archive-dump method I get this error message:

Database dump failed.

look the capture:

enter image description here

3 Answers 3


The problem seems to be in mysql.sock location. I found a solution from here: http://www.razorsql.com/docs/support_mysql_mac_mamp.html

Short answer

One way to change the socket location is to edit the MAMP start and stop scripts so that the mysql.sock location is the default. This can be done by editing the following files:







How I solved the problem

I did

drush ard -v

to see what was going on.

Executing: mysqldump --result-file /tmp/drush_tmp_1352892897_50a381e13a71d/... --no-autocommit --single-transaction --opt -Q  ... --host=localhost --user=... --password=...
Database dump failed. 

So I copied the mysqldump command and copied it to the command line and hit enter.

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect.

After this I tried several methods to solve the socket issue after I found the solution from www.razorsql.com.

  • The background for truly troubleshooting and arriving at the answers below is clearly explained over in this gem of a post: drupal.stackexchange.com/a/174128/3167 which is conveniently hidden away due to a non-generalized post title, so I'm sharing here for the next time I stumble upon this issue and forget exactly what to search for to find that post! Commented Aug 17, 2016 at 16:36

I had a similar issue, specifically when trying to use drush to pull a remote db and load it locally (drush-sql-sync). The error that I was getting was:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

What is happening here is that (at least in my case) there is no socket file at that location. The easy solution is to create a symlink:

cd /tmp
ln -s /Applications/MAMP/tmp/mysql/mysql.sock ./mysql.sock

The effect of which is to route all calls for /tmp/mysql.sock to the appropriate MAMP specific path.


I had the same issue after upgrading OSX. I tried several things, none worked for me. I had all the symbolic links already created in the first place, I kept getting the following error:

Drush was not able to start (bootstrap) the Drupal database.

I thought it was a mysql problem, but the following worked for me: I edited my ~/.bash_profile once again, adding these lines:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4.4/bin:$PATH"

export PATH
export DRUSH_PHP="/Applications/MAMP/bin/php/php5.4.4/bin/php"
export PATH=/usr/local/bin:$PATH

Restart the terminal and voila - drush works like a charm again. Thanks to C13L0.

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.