mampdrupal-8drush

Drush cannot locate mysql on localhost MAMP


Using drush commands to update Drupal 8 Core on a localhost build in MAMP, I've found that drush won't acknowledge my mysql.

From reading a few threads apparently this is due to MAMP's default locations for MYSQL location not being compatible with drush's expectation.

I've followed a few forum suggestions for fixed but so far have not had any luck.

The Latest attempt gives me this permission error:

 [warning] The command 'mysql' is required for preflight but cannot be found. 
Please install it and retry. Drush Commandline Tool 9.2.3

Other attempts:

I followed the suggestion from March 14th on this thread:

https://github.com/drush-ops/drush/issues/3464

which gave me this error:

[info] Executing: mysql --defaults-file=/private/tmp/drush_iBYWVg --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_7T1mwj [info] Executing: mysql --defaults-file=/private/tmp/drush_bvCyn3 --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_a9aRha In Connection.php line 149: [PDOException (2002)] SQLSTATE[HY000] [2002] No such file or directory

Another potential solution I tried came from Chrisblomm's answer on this thread:

Drush cannot connect to MySQL on MAMP?

Unfortunately for me that triggered the first error again:

 [warning] The command 'mysql' is required for preflight but cannot be found. 
Please install it and retry. Drush Commandline Tool 9.2.3

UPDATE: I found a solution here:

Andrew Patton's comments on this thread solved it for me:

https://stackoverflow.com/a/29990624/2639928

Specifically his tips to "define and export mysql and mysqladmin as functions".

Once I added his suggested lines of code to to my Mac's local .bash_profile it then allowed drush to correctly identify the mysql.

This meant I was able to use all the drush commands I needed that had previously triggered drush errors.


Solution

  • Andrew Patton's comments here solved it for me: https://stackoverflow.com/a/29990624/2639928 specifically his tips to "define and export mysql and mysqladmin as functions" once I added that to my mac / user / .bash_profile my drush acknowledged the mysql and I was able to use all the commands I needed that had previously given me drush errors.