Search code examples
mysqldrupalcygwinwampdrush

Drush can't connect to local MySQL through socket on WAMP


*I asked this on drupal.stackexchange, but it seems like the question relates more to Cygwin and WAMP, so I'm reposting here.

Trying to set up Drush with in a local dev environment on Windows 7 and can't get MySQL properly configured. A test command I've been running via Cygwin, with the resulting error, is as follows:

$ drush sql-query "SELECT * FROM erg_node WHERE nid=3"
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I can run the same SQL statement in phpmyadmin and it works fine. I can run the same drush command with a remote site and it also works, so it seems like it must be related to how MySQL is configured with WAMP and Cygwin. When I check which mysql via Cygwin, I get back /usr/bin/mysql instead of the path for WAMP's mysql. But the WAMP mysql path is set in my system environment PATH variable, so it should be accessible.

I've tried changing my.ini to include host = 127.0.0.1, copied the my.ini file to /etc/my.cnf, and run chmod -R 755 /tmp/. The my.ini file already included socket = /tmp/mysql.sock, and I tried adding a symlink i.e. ln -s /cygdrive/c/wamp/tmp/mysql.sock /tmp/mysql.sock. Any help would be appreciated. Thank you!

*Edit - the drush command above executes properly within Powershell, so it seems like the issue is that Cygwin is using /usr/bin/mysql instead of the WAMP mysql command. Is there a way to change which mysql command Cygwin uses?


Solution

  • Had to add the path to the version of mysql that I wanted to use (the WAMP version) to the beginning of my PATH variable in my .bash_profile, so obvious in retrospect! SO post regarding PATH variable in .bash_profile.